<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./js/coder_app.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="./rtwreport_utils.js"></script>
<script type="text/javascript" src="./rtwannotate.js"></script>
<link rel="stylesheet" type="text/css" href="./css/coder_app.css"/>
</head>
<body onload="srcFileOnload();">
<pre id="code">
<table class="code" id="codeTbl">
<tr name="1" id="1">
<td><a id="l1" class='ln'>1</a></td><td><span class="ct">/*</span></td></tr>
<tr name="2" id="2">
<td><a id="l2" class='ln'>2</a></td><td><span class="ct"> * Code generated for Simulink model VCUComposition_demo.</span></td></tr>
<tr name="3" id="3">
<td><a id="l3" class='ln'>3</a></td><td><span class="ct"> *</span></td></tr>
<tr name="4" id="4">
<td><a id="l4" class='ln'>4</a></td><td><span class="ct"> * FILE    : can.c</span></td></tr>
<tr name="5" id="5">
<td><a id="l5" class='ln'>5</a></td><td><span class="ct"> *</span></td></tr>
<tr name="6" id="6">
<td><a id="l6" class='ln'>6</a></td><td><span class="ct"> * VERSION : 1.86</span></td></tr>
<tr name="7" id="7">
<td><a id="l7" class='ln'>7</a></td><td><span class="ct"> *</span></td></tr>
<tr name="8" id="8">
<td><a id="l8" class='ln'>8</a></td><td><span class="ct"> * DATE    : Sun Sep  8 01:03:14 2024</span></td></tr>
<tr name="9" id="9">
<td><a id="l9" class='ln'>9</a></td><td><span class="ct"> *</span></td></tr>
<tr name="10" id="10">
<td><a id="l10" class='ln'>10</a></td><td><span class="ct"> * Copyright 2011-2017 ECUCoder. All Rights Reserved.</span></td></tr>
<tr name="11" id="11">
<td><a id="l11" class='ln'>11</a></td><td><span class="ct"> */</span></td></tr>
<tr name="12" id="12">
<td><a id="l12" class='ln'>12</a></td><td></td></tr>
<tr name="13" id="13">
<td><a id="l13" class='ln'>13</a></td><td><span class="pp">#include "can.h"</span></td></tr>
<tr name="14" id="14">
<td><a id="l14" class='ln'>14</a></td><td><span class="pp">#if</span> 1</td></tr>
<tr name="15" id="15">
<td><a id="l15" class='ln'>15</a></td><td></td></tr>
<tr name="16" id="16">
<td><a id="l16" class='ln'>16</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="17" id="17">
<td><a id="l17" class='ln'>17</a></td><td><span class="ct"> * FUNCTION :    ec_can0_init                                              *</span></td></tr>
<tr name="18" id="18">
<td><a id="l18" class='ln'>18</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="19" id="19">
<td><a id="l19" class='ln'>19</a></td><td><span class="ct"> * DESCRIPTION : Initialize FlexCAN0 module                                *</span></td></tr>
<tr name="20" id="20">
<td><a id="l20" class='ln'>20</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="21" id="21">
<td><a id="l21" class='ln'>21</a></td><td><span class="ct"> * PARAMETERS :  -*caninit: pointer to configuration set                   *</span></td></tr>
<tr name="22" id="22">
<td><a id="l22" class='ln'>22</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="23" id="23">
<td><a id="l23" class='ln'>23</a></td><td><span class="ct"> * RETURN:       None                                                      *</span></td></tr>
<tr name="24" id="24">
<td><a id="l24" class='ln'>24</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="25" id="25">
<td><a id="l25" class='ln'>25</a></td><td><span class="kw">void</span> <a id="25c6" class="tk">ec_can0_init</a>(<a id="25c19" class="tk">CAN_Initialization</a><a id="25c37" class="tk">*</a> <a id="25c39" class="tk">caninit</a>)</td></tr>
<tr name="26" id="26">
<td><a id="l26" class='ln'>26</a></td><td><span class="br">{</span></td></tr>
<tr name="27" id="27">
<td><a id="l27" class='ln'>27</a></td><td>  <a id="27c3" class="tk">uint8</a> <a id="27c9" class="tk">i</a>,<a id="27c11" class="tk">j</a>;</td></tr>
<tr name="28" id="28">
<td><a id="l28" class='ln'>28</a></td><td>  <a id="28c3" class="tk">CAN_0</a>.<a id="28c9" class="tk">MCR</a>.<a id="28c13" class="tk">R</a> = 0x5000003F;            <span class="ct">/* 64 message buffers in use */</span></td></tr>
<tr name="29" id="29">
<td><a id="l29" class='ln'>29</a></td><td>  <span class="kw">while</span> (<a id="29c10" class="tk">!</a><a id="29c11" class="tk">CAN_0</a>.<a id="29c17" class="tk">MCR</a>.<a id="29c21" class="tk">B</a>.<a id="29c23" class="tk">FRZACK</a>) ;</td></tr>
<tr name="30" id="30">
<td><a id="l30" class='ln'>30</a></td><td>  <a id="30c3" class="tk">FLEXCAN</a>(0).<a id="30c14" class="tk">CTRL1</a>.<a id="30c20" class="tk">B</a>.<a id="30c22" class="tk">PRESDIV</a> = 4;      <span class="ct">/* Prescaler division factor */</span></td></tr>
<tr name="31" id="31">
<td><a id="l31" class='ln'>31</a></td><td>  <a id="31c3" class="tk">FLEXCAN</a>(0).<a id="31c14" class="tk">CTRL1</a>.<a id="31c20" class="tk">B</a>.<a id="31c22" class="tk">RJW</a> = 1;          <span class="ct">/* Synchronization jump width */</span></td></tr>
<tr name="32" id="32">
<td><a id="l32" class='ln'>32</a></td><td>  <a id="32c3" class="tk">FLEXCAN</a>(0).<a id="32c14" class="tk">CTRL1</a>.<a id="32c20" class="tk">B</a>.<a id="32c22" class="tk">PSEG1</a> = 3;        <span class="ct">/* Phase segment 1 */</span></td></tr>
<tr name="33" id="33">
<td><a id="l33" class='ln'>33</a></td><td>  <a id="33c3" class="tk">FLEXCAN</a>(0).<a id="33c14" class="tk">CTRL1</a>.<a id="33c20" class="tk">B</a>.<a id="33c22" class="tk">PSEG2</a> = 3;        <span class="ct">/* Phase segment 2 */</span></td></tr>
<tr name="34" id="34">
<td><a id="l34" class='ln'>34</a></td><td>  <a id="34c3" class="tk">FLEXCAN</a>(0).<a id="34c14" class="tk">CTRL1</a>.<a id="34c20" class="tk">B</a>.<a id="34c22" class="tk">BOFFMSK</a> = 0;</td></tr>
<tr name="35" id="35">
<td><a id="l35" class='ln'>35</a></td><td>               <span class="ct">/* 1: Bus off interrupt enabled; 0: Bus off interrupt disabled */</span></td></tr>
<tr name="36" id="36">
<td><a id="l36" class='ln'>36</a></td><td>  <a id="36c3" class="tk">FLEXCAN</a>(0).<a id="36c14" class="tk">CTRL1</a>.<a id="36c20" class="tk">B</a>.<a id="36c22" class="tk">ERRMSK</a> = 0;</td></tr>
<tr name="37" id="37">
<td><a id="l37" class='ln'>37</a></td><td>                   <span class="ct">/* 1: Error interrupt enabled; 0: Error interrupt disabled */</span></td></tr>
<tr name="38" id="38">
<td><a id="l38" class='ln'>38</a></td><td>  <a id="38c3" class="tk">FLEXCAN</a>(0).<a id="38c14" class="tk">CTRL1</a>.<a id="38c20" class="tk">B</a>.<a id="38c22" class="tk">CLKSRC</a> = 0;</td></tr>
<tr name="39" id="39">
<td><a id="l39" class='ln'>39</a></td><td>             <span class="ct">/* CAN engine clock source. 0: oscillator clock; 1: system clock */</span></td></tr>
<tr name="40" id="40">
<td><a id="l40" class='ln'>40</a></td><td>  <a id="40c3" class="tk">FLEXCAN</a>(0).<a id="40c14" class="tk">CTRL1</a>.<a id="40c20" class="tk">B</a>.<a id="40c22" class="tk">LPB</a> = 0;          <span class="ct">/* Loop back disabled */</span></td></tr>
<tr name="41" id="41">
<td><a id="l41" class='ln'>41</a></td><td>  <a id="41c3" class="tk">FLEXCAN</a>(0).<a id="41c14" class="tk">CTRL1</a>.<a id="41c20" class="tk">B</a>.<a id="41c22" class="tk">SMP</a> = 0;          <span class="ct">/* Number of samples */</span></td></tr>
<tr name="42" id="42">
<td><a id="l42" class='ln'>42</a></td><td>  <a id="42c3" class="tk">FLEXCAN</a>(0).<a id="42c14" class="tk">CTRL1</a>.<a id="42c20" class="tk">B</a>.<a id="42c22" class="tk">BOFFREC</a> = 0;</td></tr>
<tr name="43" id="43">
<td><a id="l43" class='ln'>43</a></td><td>             <span class="ct">/* 0: Automatic recovering from bus off state enabled;1: disable */</span></td></tr>
<tr name="44" id="44">
<td><a id="l44" class='ln'>44</a></td><td>  <a id="44c3" class="tk">FLEXCAN</a>(0).<a id="44c14" class="tk">CTRL1</a>.<a id="44c20" class="tk">B</a>.<a id="44c22" class="tk">TSYN</a> = 0;    <span class="ct">/* 0: Timer sync feature disabled;1: enable */</span></td></tr>
<tr name="45" id="45">
<td><a id="l45" class='ln'>45</a></td><td>  <a id="45c3" class="tk">FLEXCAN</a>(0).<a id="45c14" class="tk">CTRL1</a>.<a id="45c20" class="tk">B</a>.<a id="45c22" class="tk">LBUF</a> = 0;  <span class="ct">/* 0: Buffer with lowest ID is transmitted first</span></td></tr>
<tr name="46" id="46">
<td><a id="l46" class='ln'>46</a></td><td><span class="ct">                                   1: Lowest number buffer is transmitted first */</span></td></tr>
<tr name="47" id="47">
<td><a id="l47" class='ln'>47</a></td><td>  <a id="47c3" class="tk">FLEXCAN</a>(0).<a id="47c14" class="tk">CTRL1</a>.<a id="47c20" class="tk">B</a>.<a id="47c22" class="tk">LOM</a> = 0;          <span class="ct">/* Listen-only mode disable */</span></td></tr>
<tr name="48" id="48">
<td><a id="l48" class='ln'>48</a></td><td>  <a id="48c3" class="tk">FLEXCAN</a>(0).<a id="48c14" class="tk">CTRL1</a>.<a id="48c20" class="tk">B</a>.<a id="48c22" class="tk">PROPSEG</a> = 6;</td></tr>
<tr name="49" id="49">
<td><a id="l49" class='ln'>49</a></td><td>             <span class="ct">/* Defines the length of the propagation segment in the bit time */</span></td></tr>
<tr name="50" id="50">
<td><a id="l50" class='ln'>50</a></td><td>  <span class="kw">for</span> (<a id="50c8" class="tk">i</a>=0; <a id="50c13" class="tk">i</a><a id="50c14" class="tk">&lt;</a><a id="50c15" class="tk">NumCanMaxMB</a>; <a id="50c28" class="tk">i</a><a id="50c29" class="tk">++</a>)</td></tr>
<tr name="51" id="51">
<td><a id="l51" class='ln'>51</a></td><td>                         <span class="ct">/* Initialize message buffer for receive or transmit */</span></td></tr>
<tr name="52" id="52">
<td><a id="l52" class='ln'>52</a></td><td>  <span class="br">{</span></td></tr>
<tr name="53" id="53">
<td><a id="l53" class='ln'>53</a></td><td>    <a id="53c5" class="tk">FLEXCAN</a>(0).<a id="53c16" class="tk">MB</a>[<a id="53c19" class="tk">i</a>].<a id="53c22" class="tk">CS</a>.<a id="53c25" class="tk">R</a> = <a id="53c29" class="tk">caninit</a>-&gt;<a id="53c38" class="tk">MBCS</a>[<a id="53c43" class="tk">i</a>];</td></tr>
<tr name="54" id="54">
<td><a id="l54" class='ln'>54</a></td><td>    <span class="kw">for</span> (<a id="54c10" class="tk">j</a>=0; <a id="54c15" class="tk">j</a><a id="54c16" class="tk">&lt;</a>8; <a id="54c20" class="tk">j</a><a id="54c21" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="55" id="55">
<td><a id="l55" class='ln'>55</a></td><td>      <a id="55c7" class="tk">FLEXCAN</a>(0).<a id="55c18" class="tk">MB</a>[<a id="55c21" class="tk">i</a>].<a id="55c24" class="tk">DATA</a>.<a id="55c29" class="tk">B</a>[<a id="55c31" class="tk">j</a>] = 0;</td></tr>
<tr name="56" id="56">
<td><a id="l56" class='ln'>56</a></td><td>    <span class="br">}</span></td></tr>
<tr name="57" id="57">
<td><a id="l57" class='ln'>57</a></td><td>  <span class="br">}</span></td></tr>
<tr name="58" id="58">
<td><a id="l58" class='ln'>58</a></td><td></td></tr>
<tr name="59" id="59">
<td><a id="l59" class='ln'>59</a></td><td>  <a id="59c3" class="tk">FLEXCAN</a>(0).<a id="59c14" class="tk">MB</a>[14].<a id="59c21" class="tk">ID</a>.<a id="59c24" class="tk">R</a> = 0;</td></tr>
<tr name="60" id="60">
<td><a id="l60" class='ln'>60</a></td><td>  <a id="60c3" class="tk">FLEXCAN</a>(0).<a id="60c14" class="tk">RXMGMASK</a>.<a id="60c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="61" id="61">
<td><a id="l61" class='ln'>61</a></td><td>  <a id="61c3" class="tk">FLEXCAN</a>(0).<a id="61c14" class="tk">RX14MASK</a>.<a id="61c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="62" id="62">
<td><a id="l62" class='ln'>62</a></td><td>  <a id="62c3" class="tk">FLEXCAN</a>(0).<a id="62c14" class="tk">RX15MASK</a>.<a id="62c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="63" id="63">
<td><a id="l63" class='ln'>63</a></td><td>  <a id="63c3" class="tk">FLEXCAN</a>(0).<a id="63c14" class="tk">RXFGMASK</a>.<a id="63c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="64" id="64">
<td><a id="l64" class='ln'>64</a></td><td>  <a id="64c3" class="tk">FLEXCAN</a>(0).<a id="64c14" class="tk">ECR</a>.<a id="64c18" class="tk">R</a> = 0;</td></tr>
<tr name="65" id="65">
<td><a id="l65" class='ln'>65</a></td><td>  <a id="65c3" class="tk">FLEXCAN</a>(0).<a id="65c14" class="tk">IMASK2</a>.<a id="65c21" class="tk">R</a> = 0;</td></tr>
<tr name="66" id="66">
<td><a id="l66" class='ln'>66</a></td><td>  <a id="66c3" class="tk">FLEXCAN</a>(0).<a id="66c14" class="tk">IFLAG2</a>.<a id="66c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="67" id="67">
<td><a id="l67" class='ln'>67</a></td><td>  <a id="67c3" class="tk">FLEXCAN</a>(0).<a id="67c14" class="tk">IFLAG1</a>.<a id="67c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="68" id="68">
<td><a id="l68" class='ln'>68</a></td><td>  <a id="68c3" class="tk">FLEXCAN</a>(0).<a id="68c14" class="tk">ESR1</a>.<a id="68c19" class="tk">R</a> = <a id="68c23" class="tk">CAN_ERRINT</a><a id="68c33" class="tk">|</a><a id="68c34" class="tk">CAN_BOFFINT</a>;</td></tr>
<tr name="69" id="69">
<td><a id="l69" class='ln'>69</a></td><td>                             <span class="ct">/* Error interrupt flag &amp; Bus off interrupt flag */</span></td></tr>
<tr name="70" id="70">
<td><a id="l70" class='ln'>70</a></td><td>  <a id="70c3" class="tk">FLEXCAN</a>(0).<a id="70c14" class="tk">MCR</a>.<a id="70c18" class="tk">R</a> = <a id="70c22" class="tk">CAN_NORMAL_MODE</a><a id="70c37" class="tk">|</a><a id="70c38" class="tk">NUM_OF_ENABLED_MB</a>;<span class="ct">/* Normal mode */</span></td></tr>
<tr name="71" id="71">
<td><a id="l71" class='ln'>71</a></td><td>  <a id="71c3" class="tk">FLEXCAN</a>(0).<a id="71c14" class="tk">MCR</a>.<a id="71c18" class="tk">B</a>.<a id="71c20" class="tk">HALT</a> = 0;</td></tr>
<tr name="72" id="72">
<td><a id="l72" class='ln'>72</a></td><td>                         <span class="ct">/* FlexCAN0 attempts to synchronize with the CAN bus */</span></td></tr>
<tr name="73" id="73">
<td><a id="l73" class='ln'>73</a></td><td><span class="br">}</span></td></tr>
<tr name="74" id="74">
<td><a id="l74" class='ln'>74</a></td><td></td></tr>
<tr name="75" id="75">
<td><a id="l75" class='ln'>75</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="76" id="76">
<td><a id="l76" class='ln'>76</a></td><td></td></tr>
<tr name="77" id="77">
<td><a id="l77" class='ln'>77</a></td><td><span class="pp">#if</span> 1</td></tr>
<tr name="78" id="78">
<td><a id="l78" class='ln'>78</a></td><td></td></tr>
<tr name="79" id="79">
<td><a id="l79" class='ln'>79</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="80" id="80">
<td><a id="l80" class='ln'>80</a></td><td><span class="ct"> * FUNCTION :    ec_can1_init                                              *</span></td></tr>
<tr name="81" id="81">
<td><a id="l81" class='ln'>81</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="82" id="82">
<td><a id="l82" class='ln'>82</a></td><td><span class="ct"> * DESCRIPTION : Initialize FlexCAN1 module                                *</span></td></tr>
<tr name="83" id="83">
<td><a id="l83" class='ln'>83</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="84" id="84">
<td><a id="l84" class='ln'>84</a></td><td><span class="ct"> * PARAMETERS :  -*caninit: pointer to configuration set                   *</span></td></tr>
<tr name="85" id="85">
<td><a id="l85" class='ln'>85</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="86" id="86">
<td><a id="l86" class='ln'>86</a></td><td><span class="ct"> * RETURN:       None                                                      *</span></td></tr>
<tr name="87" id="87">
<td><a id="l87" class='ln'>87</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="88" id="88">
<td><a id="l88" class='ln'>88</a></td><td><span class="kw">void</span> <a id="88c6" class="tk">ec_can1_init</a>(<a id="88c19" class="tk">CAN_Initialization</a><a id="88c37" class="tk">*</a> <a id="88c39" class="tk">caninit</a>)</td></tr>
<tr name="89" id="89">
<td><a id="l89" class='ln'>89</a></td><td><span class="br">{</span></td></tr>
<tr name="90" id="90">
<td><a id="l90" class='ln'>90</a></td><td>  <a id="90c3" class="tk">uint8</a> <a id="90c9" class="tk">i</a>,<a id="90c11" class="tk">j</a>;</td></tr>
<tr name="91" id="91">
<td><a id="l91" class='ln'>91</a></td><td>  <a id="91c3" class="tk">CAN_1</a>.<a id="91c9" class="tk">MCR</a>.<a id="91c13" class="tk">R</a> = 0x5000003F;            <span class="ct">/* 64 message buffers in use */</span></td></tr>
<tr name="92" id="92">
<td><a id="l92" class='ln'>92</a></td><td>  <span class="kw">while</span> (<a id="92c10" class="tk">!</a><a id="92c11" class="tk">CAN_1</a>.<a id="92c17" class="tk">MCR</a>.<a id="92c21" class="tk">B</a>.<a id="92c23" class="tk">FRZACK</a>) ;</td></tr>
<tr name="93" id="93">
<td><a id="l93" class='ln'>93</a></td><td>  <a id="93c3" class="tk">FLEXCAN</a>(1).<a id="93c14" class="tk">CTRL1</a>.<a id="93c20" class="tk">B</a>.<a id="93c22" class="tk">PRESDIV</a> = 4;      <span class="ct">/* Prescaler division factor */</span></td></tr>
<tr name="94" id="94">
<td><a id="l94" class='ln'>94</a></td><td>  <a id="94c3" class="tk">FLEXCAN</a>(1).<a id="94c14" class="tk">CTRL1</a>.<a id="94c20" class="tk">B</a>.<a id="94c22" class="tk">RJW</a> = 1;          <span class="ct">/* Synchronization jump width */</span></td></tr>
<tr name="95" id="95">
<td><a id="l95" class='ln'>95</a></td><td>  <a id="95c3" class="tk">FLEXCAN</a>(1).<a id="95c14" class="tk">CTRL1</a>.<a id="95c20" class="tk">B</a>.<a id="95c22" class="tk">PSEG1</a> = 3;        <span class="ct">/* Phase segment 1 */</span></td></tr>
<tr name="96" id="96">
<td><a id="l96" class='ln'>96</a></td><td>  <a id="96c3" class="tk">FLEXCAN</a>(1).<a id="96c14" class="tk">CTRL1</a>.<a id="96c20" class="tk">B</a>.<a id="96c22" class="tk">PSEG2</a> = 3;        <span class="ct">/* Phase segment 2 */</span></td></tr>
<tr name="97" id="97">
<td><a id="l97" class='ln'>97</a></td><td>  <a id="97c3" class="tk">FLEXCAN</a>(1).<a id="97c14" class="tk">CTRL1</a>.<a id="97c20" class="tk">B</a>.<a id="97c22" class="tk">BOFFMSK</a> = 0;</td></tr>
<tr name="98" id="98">
<td><a id="l98" class='ln'>98</a></td><td>               <span class="ct">/* 1: Bus off interrupt enabled; 0: Bus off interrupt disabled */</span></td></tr>
<tr name="99" id="99">
<td><a id="l99" class='ln'>99</a></td><td>  <a id="99c3" class="tk">FLEXCAN</a>(1).<a id="99c14" class="tk">CTRL1</a>.<a id="99c20" class="tk">B</a>.<a id="99c22" class="tk">ERRMSK</a> = 0;</td></tr>
<tr name="100" id="100">
<td><a id="l100" class='ln'>100</a></td><td>                   <span class="ct">/* 1: Error interrupt enabled; 0: Error interrupt disabled */</span></td></tr>
<tr name="101" id="101">
<td><a id="l101" class='ln'>101</a></td><td>  <a id="101c3" class="tk">FLEXCAN</a>(1).<a id="101c14" class="tk">CTRL1</a>.<a id="101c20" class="tk">B</a>.<a id="101c22" class="tk">CLKSRC</a> = 0;</td></tr>
<tr name="102" id="102">
<td><a id="l102" class='ln'>102</a></td><td>             <span class="ct">/* CAN engine clock source. 0: oscillator clock; 1: system clock */</span></td></tr>
<tr name="103" id="103">
<td><a id="l103" class='ln'>103</a></td><td>  <a id="103c3" class="tk">FLEXCAN</a>(1).<a id="103c14" class="tk">CTRL1</a>.<a id="103c20" class="tk">B</a>.<a id="103c22" class="tk">LPB</a> = 0;          <span class="ct">/* 0: Loop back disabled */</span></td></tr>
<tr name="104" id="104">
<td><a id="l104" class='ln'>104</a></td><td>  <a id="104c3" class="tk">FLEXCAN</a>(1).<a id="104c14" class="tk">CTRL1</a>.<a id="104c20" class="tk">B</a>.<a id="104c22" class="tk">SMP</a> = 0;          <span class="ct">/* Number of samples */</span></td></tr>
<tr name="105" id="105">
<td><a id="l105" class='ln'>105</a></td><td>  <a id="105c3" class="tk">FLEXCAN</a>(1).<a id="105c14" class="tk">CTRL1</a>.<a id="105c20" class="tk">B</a>.<a id="105c22" class="tk">BOFFREC</a> = 0;</td></tr>
<tr name="106" id="106">
<td><a id="l106" class='ln'>106</a></td><td>            <span class="ct">/* 0: Automatic recovering from bus off state enabled; 1: disable */</span></td></tr>
<tr name="107" id="107">
<td><a id="l107" class='ln'>107</a></td><td>  <a id="107c3" class="tk">FLEXCAN</a>(1).<a id="107c14" class="tk">CTRL1</a>.<a id="107c20" class="tk">B</a>.<a id="107c22" class="tk">TSYN</a> = 0;   <span class="ct">/* 0: Timer sync feature disabled; 1: enable */</span></td></tr>
<tr name="108" id="108">
<td><a id="l108" class='ln'>108</a></td><td>  <a id="108c3" class="tk">FLEXCAN</a>(1).<a id="108c14" class="tk">CTRL1</a>.<a id="108c20" class="tk">B</a>.<a id="108c22" class="tk">LBUF</a> = 0;  <span class="ct">/* 0: Buffer with lowest ID is transmitted first</span></td></tr>
<tr name="109" id="109">
<td><a id="l109" class='ln'>109</a></td><td><span class="ct">                                   1: Lowest number buffer is transmitted first */</span></td></tr>
<tr name="110" id="110">
<td><a id="l110" class='ln'>110</a></td><td>  <a id="110c3" class="tk">FLEXCAN</a>(1).<a id="110c14" class="tk">CTRL1</a>.<a id="110c20" class="tk">B</a>.<a id="110c22" class="tk">LOM</a> = 0;          <span class="ct">/* Listen-only mode disable */</span></td></tr>
<tr name="111" id="111">
<td><a id="l111" class='ln'>111</a></td><td>  <a id="111c3" class="tk">FLEXCAN</a>(1).<a id="111c14" class="tk">CTRL1</a>.<a id="111c20" class="tk">B</a>.<a id="111c22" class="tk">PROPSEG</a> = 6;</td></tr>
<tr name="112" id="112">
<td><a id="l112" class='ln'>112</a></td><td>             <span class="ct">/* Defines the length of the propagation segment in the bit time */</span></td></tr>
<tr name="113" id="113">
<td><a id="l113" class='ln'>113</a></td><td>  <span class="kw">for</span> (<a id="113c8" class="tk">i</a>=0; <a id="113c13" class="tk">i</a><a id="113c14" class="tk">&lt;</a><a id="113c15" class="tk">NumCanMaxMB</a>; <a id="113c28" class="tk">i</a><a id="113c29" class="tk">++</a>)</td></tr>
<tr name="114" id="114">
<td><a id="l114" class='ln'>114</a></td><td>                        <span class="ct">/* Initialize message buffer for receive or transmit  */</span></td></tr>
<tr name="115" id="115">
<td><a id="l115" class='ln'>115</a></td><td>  <span class="br">{</span></td></tr>
<tr name="116" id="116">
<td><a id="l116" class='ln'>116</a></td><td>    <a id="116c5" class="tk">FLEXCAN</a>(1).<a id="116c16" class="tk">MB</a>[<a id="116c19" class="tk">i</a>].<a id="116c22" class="tk">CS</a>.<a id="116c25" class="tk">R</a> = <a id="116c29" class="tk">caninit</a>-&gt;<a id="116c38" class="tk">MBCS</a>[<a id="116c43" class="tk">i</a>];</td></tr>
<tr name="117" id="117">
<td><a id="l117" class='ln'>117</a></td><td>    <span class="kw">for</span> (<a id="117c10" class="tk">j</a>=0; <a id="117c15" class="tk">j</a><a id="117c16" class="tk">&lt;</a>8; <a id="117c20" class="tk">j</a><a id="117c21" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="118" id="118">
<td><a id="l118" class='ln'>118</a></td><td>      <a id="118c7" class="tk">FLEXCAN</a>(1).<a id="118c18" class="tk">MB</a>[<a id="118c21" class="tk">i</a>].<a id="118c24" class="tk">DATA</a>.<a id="118c29" class="tk">B</a>[<a id="118c31" class="tk">j</a>] = 0;</td></tr>
<tr name="119" id="119">
<td><a id="l119" class='ln'>119</a></td><td>    <span class="br">}</span></td></tr>
<tr name="120" id="120">
<td><a id="l120" class='ln'>120</a></td><td>  <span class="br">}</span></td></tr>
<tr name="121" id="121">
<td><a id="l121" class='ln'>121</a></td><td></td></tr>
<tr name="122" id="122">
<td><a id="l122" class='ln'>122</a></td><td>  <a id="122c3" class="tk">FLEXCAN</a>(1).<a id="122c14" class="tk">MB</a>[14].<a id="122c21" class="tk">ID</a>.<a id="122c24" class="tk">R</a> = 0;</td></tr>
<tr name="123" id="123">
<td><a id="l123" class='ln'>123</a></td><td>  <a id="123c3" class="tk">FLEXCAN</a>(1).<a id="123c14" class="tk">RXMGMASK</a>.<a id="123c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="124" id="124">
<td><a id="l124" class='ln'>124</a></td><td>  <a id="124c3" class="tk">FLEXCAN</a>(1).<a id="124c14" class="tk">RX14MASK</a>.<a id="124c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="125" id="125">
<td><a id="l125" class='ln'>125</a></td><td>  <a id="125c3" class="tk">FLEXCAN</a>(1).<a id="125c14" class="tk">RX15MASK</a>.<a id="125c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="126" id="126">
<td><a id="l126" class='ln'>126</a></td><td>  <a id="126c3" class="tk">FLEXCAN</a>(1).<a id="126c14" class="tk">RXFGMASK</a>.<a id="126c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="127" id="127">
<td><a id="l127" class='ln'>127</a></td><td>  <a id="127c3" class="tk">FLEXCAN</a>(1).<a id="127c14" class="tk">ECR</a>.<a id="127c18" class="tk">R</a> = 0;</td></tr>
<tr name="128" id="128">
<td><a id="l128" class='ln'>128</a></td><td>  <a id="128c3" class="tk">FLEXCAN</a>(1).<a id="128c14" class="tk">IMASK2</a>.<a id="128c21" class="tk">R</a> = 0;</td></tr>
<tr name="129" id="129">
<td><a id="l129" class='ln'>129</a></td><td>  <a id="129c3" class="tk">FLEXCAN</a>(1).<a id="129c14" class="tk">IFLAG2</a>.<a id="129c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="130" id="130">
<td><a id="l130" class='ln'>130</a></td><td>  <a id="130c3" class="tk">FLEXCAN</a>(1).<a id="130c14" class="tk">IFLAG1</a>.<a id="130c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="131" id="131">
<td><a id="l131" class='ln'>131</a></td><td>  <a id="131c3" class="tk">FLEXCAN</a>(1).<a id="131c14" class="tk">ESR1</a>.<a id="131c19" class="tk">R</a> = <a id="131c23" class="tk">CAN_ERRINT</a><a id="131c33" class="tk">|</a><a id="131c34" class="tk">CAN_BOFFINT</a>;</td></tr>
<tr name="132" id="132">
<td><a id="l132" class='ln'>132</a></td><td>                             <span class="ct">/* Error interrupt flag &amp; Bus off interrupt flag */</span></td></tr>
<tr name="133" id="133">
<td><a id="l133" class='ln'>133</a></td><td>  <a id="133c3" class="tk">FLEXCAN</a>(1).<a id="133c14" class="tk">MCR</a>.<a id="133c18" class="tk">R</a> = <a id="133c22" class="tk">CAN_NORMAL_MODE</a><a id="133c37" class="tk">|</a><a id="133c38" class="tk">NUM_OF_ENABLED_MB</a>;<span class="ct">/* Normal mode */</span></td></tr>
<tr name="134" id="134">
<td><a id="l134" class='ln'>134</a></td><td>  <a id="134c3" class="tk">FLEXCAN</a>(1).<a id="134c14" class="tk">MCR</a>.<a id="134c18" class="tk">B</a>.<a id="134c20" class="tk">HALT</a> = 0;</td></tr>
<tr name="135" id="135">
<td><a id="l135" class='ln'>135</a></td><td>                         <span class="ct">/* FlexCAN1 attempts to synchronize with the CAN bus */</span></td></tr>
<tr name="136" id="136">
<td><a id="l136" class='ln'>136</a></td><td><span class="br">}</span></td></tr>
<tr name="137" id="137">
<td><a id="l137" class='ln'>137</a></td><td></td></tr>
<tr name="138" id="138">
<td><a id="l138" class='ln'>138</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="139" id="139">
<td><a id="l139" class='ln'>139</a></td><td></td></tr>
<tr name="140" id="140">
<td><a id="l140" class='ln'>140</a></td><td><span class="pp">#if</span> 1</td></tr>
<tr name="141" id="141">
<td><a id="l141" class='ln'>141</a></td><td></td></tr>
<tr name="142" id="142">
<td><a id="l142" class='ln'>142</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="143" id="143">
<td><a id="l143" class='ln'>143</a></td><td><span class="ct"> * FUNCTION :    ec_can2_init                                              *</span></td></tr>
<tr name="144" id="144">
<td><a id="l144" class='ln'>144</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="145" id="145">
<td><a id="l145" class='ln'>145</a></td><td><span class="ct"> * DESCRIPTION : Initialize FlexCAN2 module                                *</span></td></tr>
<tr name="146" id="146">
<td><a id="l146" class='ln'>146</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="147" id="147">
<td><a id="l147" class='ln'>147</a></td><td><span class="ct"> * PARAMETERS :  -*caninit: pointer to configuration set                   *</span></td></tr>
<tr name="148" id="148">
<td><a id="l148" class='ln'>148</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="149" id="149">
<td><a id="l149" class='ln'>149</a></td><td><span class="ct"> * RETURN :      None                                                      *</span></td></tr>
<tr name="150" id="150">
<td><a id="l150" class='ln'>150</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="151" id="151">
<td><a id="l151" class='ln'>151</a></td><td><span class="kw">void</span> <a id="151c6" class="tk">ec_can2_init</a>(<a id="151c19" class="tk">CAN_Initialization</a><a id="151c37" class="tk">*</a> <a id="151c39" class="tk">caninit</a>)</td></tr>
<tr name="152" id="152">
<td><a id="l152" class='ln'>152</a></td><td><span class="br">{</span></td></tr>
<tr name="153" id="153">
<td><a id="l153" class='ln'>153</a></td><td>  <a id="153c3" class="tk">uint8</a> <a id="153c9" class="tk">i</a>,<a id="153c11" class="tk">j</a>;</td></tr>
<tr name="154" id="154">
<td><a id="l154" class='ln'>154</a></td><td>  <a id="154c3" class="tk">CAN_2</a>.<a id="154c9" class="tk">MCR</a>.<a id="154c13" class="tk">R</a> = 0x5000003F;            <span class="ct">/* 64 message buffers in use */</span></td></tr>
<tr name="155" id="155">
<td><a id="l155" class='ln'>155</a></td><td>  <span class="kw">while</span> (<a id="155c10" class="tk">!</a><a id="155c11" class="tk">CAN_2</a>.<a id="155c17" class="tk">MCR</a>.<a id="155c21" class="tk">B</a>.<a id="155c23" class="tk">FRZACK</a>) ;</td></tr>
<tr name="156" id="156">
<td><a id="l156" class='ln'>156</a></td><td>  <a id="156c3" class="tk">FLEXCAN</a>(2).<a id="156c14" class="tk">CTRL1</a>.<a id="156c20" class="tk">B</a>.<a id="156c22" class="tk">PRESDIV</a> = 4;      <span class="ct">/* Prescaler division factor */</span></td></tr>
<tr name="157" id="157">
<td><a id="l157" class='ln'>157</a></td><td>  <a id="157c3" class="tk">FLEXCAN</a>(2).<a id="157c14" class="tk">CTRL1</a>.<a id="157c20" class="tk">B</a>.<a id="157c22" class="tk">RJW</a> = 1;          <span class="ct">/* Synchronization jump width */</span></td></tr>
<tr name="158" id="158">
<td><a id="l158" class='ln'>158</a></td><td>  <a id="158c3" class="tk">FLEXCAN</a>(2).<a id="158c14" class="tk">CTRL1</a>.<a id="158c20" class="tk">B</a>.<a id="158c22" class="tk">PSEG1</a> = 3;        <span class="ct">/* Phase segment 1 */</span></td></tr>
<tr name="159" id="159">
<td><a id="l159" class='ln'>159</a></td><td>  <a id="159c3" class="tk">FLEXCAN</a>(2).<a id="159c14" class="tk">CTRL1</a>.<a id="159c20" class="tk">B</a>.<a id="159c22" class="tk">PSEG2</a> = 3;        <span class="ct">/* Phase segment 2 */</span></td></tr>
<tr name="160" id="160">
<td><a id="l160" class='ln'>160</a></td><td>  <a id="160c3" class="tk">FLEXCAN</a>(2).<a id="160c14" class="tk">CTRL1</a>.<a id="160c20" class="tk">B</a>.<a id="160c22" class="tk">BOFFMSK</a> = 0;</td></tr>
<tr name="161" id="161">
<td><a id="l161" class='ln'>161</a></td><td>               <span class="ct">/* 1: Bus off interrupt enabled; 0: Bus off interrupt disabled */</span></td></tr>
<tr name="162" id="162">
<td><a id="l162" class='ln'>162</a></td><td>  <a id="162c3" class="tk">FLEXCAN</a>(2).<a id="162c14" class="tk">CTRL1</a>.<a id="162c20" class="tk">B</a>.<a id="162c22" class="tk">ERRMSK</a> = 0;</td></tr>
<tr name="163" id="163">
<td><a id="l163" class='ln'>163</a></td><td>                   <span class="ct">/* 1: Error interrupt enabled; 0: Error interrupt disabled */</span></td></tr>
<tr name="164" id="164">
<td><a id="l164" class='ln'>164</a></td><td>  <a id="164c3" class="tk">FLEXCAN</a>(2).<a id="164c14" class="tk">CTRL1</a>.<a id="164c20" class="tk">B</a>.<a id="164c22" class="tk">CLKSRC</a> = 0;</td></tr>
<tr name="165" id="165">
<td><a id="l165" class='ln'>165</a></td><td>             <span class="ct">/* CAN engine clock source. 0: oscillator clock; 1: system clock */</span></td></tr>
<tr name="166" id="166">
<td><a id="l166" class='ln'>166</a></td><td>  <a id="166c3" class="tk">FLEXCAN</a>(2).<a id="166c14" class="tk">CTRL1</a>.<a id="166c20" class="tk">B</a>.<a id="166c22" class="tk">LPB</a> = 0;          <span class="ct">/* 0: Loop back disabled */</span></td></tr>
<tr name="167" id="167">
<td><a id="l167" class='ln'>167</a></td><td>  <a id="167c3" class="tk">FLEXCAN</a>(2).<a id="167c14" class="tk">CTRL1</a>.<a id="167c20" class="tk">B</a>.<a id="167c22" class="tk">SMP</a> = 0;          <span class="ct">/* Number of samples */</span></td></tr>
<tr name="168" id="168">
<td><a id="l168" class='ln'>168</a></td><td>  <a id="168c3" class="tk">FLEXCAN</a>(2).<a id="168c14" class="tk">CTRL1</a>.<a id="168c20" class="tk">B</a>.<a id="168c22" class="tk">BOFFREC</a> = 0;</td></tr>
<tr name="169" id="169">
<td><a id="l169" class='ln'>169</a></td><td>            <span class="ct">/* 0: Automatic recovering from bus off state enabled; 1: disable */</span></td></tr>
<tr name="170" id="170">
<td><a id="l170" class='ln'>170</a></td><td>  <a id="170c3" class="tk">FLEXCAN</a>(2).<a id="170c14" class="tk">CTRL1</a>.<a id="170c20" class="tk">B</a>.<a id="170c22" class="tk">TSYN</a> = 0;   <span class="ct">/* 0: Timer sync feature disabled; 1: enable */</span></td></tr>
<tr name="171" id="171">
<td><a id="l171" class='ln'>171</a></td><td>  <a id="171c3" class="tk">FLEXCAN</a>(2).<a id="171c14" class="tk">CTRL1</a>.<a id="171c20" class="tk">B</a>.<a id="171c22" class="tk">LBUF</a> = 0;  <span class="ct">/* 0: Buffer with lowest ID is transmitted first</span></td></tr>
<tr name="172" id="172">
<td><a id="l172" class='ln'>172</a></td><td><span class="ct">                                   1: Lowest number buffer is transmitted first */</span></td></tr>
<tr name="173" id="173">
<td><a id="l173" class='ln'>173</a></td><td>  <a id="173c3" class="tk">FLEXCAN</a>(2).<a id="173c14" class="tk">CTRL1</a>.<a id="173c20" class="tk">B</a>.<a id="173c22" class="tk">LOM</a> = 0;          <span class="ct">/* Listen-only mode disable */</span></td></tr>
<tr name="174" id="174">
<td><a id="l174" class='ln'>174</a></td><td>  <a id="174c3" class="tk">FLEXCAN</a>(2).<a id="174c14" class="tk">CTRL1</a>.<a id="174c20" class="tk">B</a>.<a id="174c22" class="tk">PROPSEG</a> = 6;</td></tr>
<tr name="175" id="175">
<td><a id="l175" class='ln'>175</a></td><td>             <span class="ct">/* Defines the length of the propagation segment in the bit time */</span></td></tr>
<tr name="176" id="176">
<td><a id="l176" class='ln'>176</a></td><td>  <span class="kw">for</span> (<a id="176c8" class="tk">i</a>=0; <a id="176c13" class="tk">i</a><a id="176c14" class="tk">&lt;</a><a id="176c15" class="tk">NumCanMaxMB</a>; <a id="176c28" class="tk">i</a><a id="176c29" class="tk">++</a>)</td></tr>
<tr name="177" id="177">
<td><a id="l177" class='ln'>177</a></td><td>                         <span class="ct">/* Initialize message buffer for receive or transmit */</span></td></tr>
<tr name="178" id="178">
<td><a id="l178" class='ln'>178</a></td><td>  <span class="br">{</span></td></tr>
<tr name="179" id="179">
<td><a id="l179" class='ln'>179</a></td><td>    <a id="179c5" class="tk">FLEXCAN</a>(2).<a id="179c16" class="tk">MB</a>[<a id="179c19" class="tk">i</a>].<a id="179c22" class="tk">CS</a>.<a id="179c25" class="tk">R</a> = <a id="179c29" class="tk">caninit</a>-&gt;<a id="179c38" class="tk">MBCS</a>[<a id="179c43" class="tk">i</a>];</td></tr>
<tr name="180" id="180">
<td><a id="l180" class='ln'>180</a></td><td>    <span class="kw">for</span> (<a id="180c10" class="tk">j</a>=0; <a id="180c15" class="tk">j</a><a id="180c16" class="tk">&lt;</a>8; <a id="180c20" class="tk">j</a><a id="180c21" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="181" id="181">
<td><a id="l181" class='ln'>181</a></td><td>      <a id="181c7" class="tk">FLEXCAN</a>(2).<a id="181c18" class="tk">MB</a>[<a id="181c21" class="tk">i</a>].<a id="181c24" class="tk">DATA</a>.<a id="181c29" class="tk">B</a>[<a id="181c31" class="tk">j</a>] = 0;</td></tr>
<tr name="182" id="182">
<td><a id="l182" class='ln'>182</a></td><td>    <span class="br">}</span></td></tr>
<tr name="183" id="183">
<td><a id="l183" class='ln'>183</a></td><td>  <span class="br">}</span></td></tr>
<tr name="184" id="184">
<td><a id="l184" class='ln'>184</a></td><td></td></tr>
<tr name="185" id="185">
<td><a id="l185" class='ln'>185</a></td><td>  <a id="185c3" class="tk">FLEXCAN</a>(2).<a id="185c14" class="tk">MB</a>[14].<a id="185c21" class="tk">ID</a>.<a id="185c24" class="tk">R</a> = 0;</td></tr>
<tr name="186" id="186">
<td><a id="l186" class='ln'>186</a></td><td>  <a id="186c3" class="tk">FLEXCAN</a>(2).<a id="186c14" class="tk">RXMGMASK</a>.<a id="186c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="187" id="187">
<td><a id="l187" class='ln'>187</a></td><td>  <a id="187c3" class="tk">FLEXCAN</a>(2).<a id="187c14" class="tk">RX14MASK</a>.<a id="187c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="188" id="188">
<td><a id="l188" class='ln'>188</a></td><td>  <a id="188c3" class="tk">FLEXCAN</a>(2).<a id="188c14" class="tk">RX15MASK</a>.<a id="188c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="189" id="189">
<td><a id="l189" class='ln'>189</a></td><td>  <a id="189c3" class="tk">FLEXCAN</a>(2).<a id="189c14" class="tk">RXFGMASK</a>.<a id="189c23" class="tk">R</a> = 0xFFFFFFFF;</td></tr>
<tr name="190" id="190">
<td><a id="l190" class='ln'>190</a></td><td>  <a id="190c3" class="tk">FLEXCAN</a>(2).<a id="190c14" class="tk">ECR</a>.<a id="190c18" class="tk">R</a> = 0;</td></tr>
<tr name="191" id="191">
<td><a id="l191" class='ln'>191</a></td><td>  <a id="191c3" class="tk">FLEXCAN</a>(2).<a id="191c14" class="tk">IMASK2</a>.<a id="191c21" class="tk">R</a> = 0;</td></tr>
<tr name="192" id="192">
<td><a id="l192" class='ln'>192</a></td><td>  <a id="192c3" class="tk">FLEXCAN</a>(2).<a id="192c14" class="tk">IFLAG2</a>.<a id="192c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="193" id="193">
<td><a id="l193" class='ln'>193</a></td><td>  <a id="193c3" class="tk">FLEXCAN</a>(2).<a id="193c14" class="tk">IFLAG1</a>.<a id="193c21" class="tk">R</a> = 0xFFFFFFFF;    <span class="ct">/* Clear interruput flag */</span></td></tr>
<tr name="194" id="194">
<td><a id="l194" class='ln'>194</a></td><td>  <a id="194c3" class="tk">FLEXCAN</a>(2).<a id="194c14" class="tk">ESR1</a>.<a id="194c19" class="tk">R</a> = <a id="194c23" class="tk">CAN_ERRINT</a><a id="194c33" class="tk">|</a><a id="194c34" class="tk">CAN_BOFFINT</a>;</td></tr>
<tr name="195" id="195">
<td><a id="l195" class='ln'>195</a></td><td>                             <span class="ct">/* Error interrupt flag &amp; Bus off interrupt flag */</span></td></tr>
<tr name="196" id="196">
<td><a id="l196" class='ln'>196</a></td><td>  <a id="196c3" class="tk">FLEXCAN</a>(2).<a id="196c14" class="tk">MCR</a>.<a id="196c18" class="tk">R</a> = <a id="196c22" class="tk">CAN_NORMAL_MODE</a><a id="196c37" class="tk">|</a><a id="196c38" class="tk">NUM_OF_ENABLED_MB</a>;<span class="ct">/* Normal mode */</span></td></tr>
<tr name="197" id="197">
<td><a id="l197" class='ln'>197</a></td><td>  <a id="197c3" class="tk">FLEXCAN</a>(2).<a id="197c14" class="tk">MCR</a>.<a id="197c18" class="tk">B</a>.<a id="197c20" class="tk">HALT</a> = 0;</td></tr>
<tr name="198" id="198">
<td><a id="l198" class='ln'>198</a></td><td>                         <span class="ct">/* FlexCAN2 attempts to synchronize with the CAN bus */</span></td></tr>
<tr name="199" id="199">
<td><a id="l199" class='ln'>199</a></td><td><span class="br">}</span></td></tr>
<tr name="200" id="200">
<td><a id="l200" class='ln'>200</a></td><td></td></tr>
<tr name="201" id="201">
<td><a id="l201" class='ln'>201</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="202" id="202">
<td><a id="l202" class='ln'>202</a></td><td></td></tr>
<tr name="203" id="203">
<td><a id="l203" class='ln'>203</a></td><td><span class="pp">#if</span> <a id="203c5" class="tk">CANAENABLE</a><a id="203c15" class="tk">||</a><a id="203c17" class="tk">CANBENABLE</a><a id="203c27" class="tk">||</a><a id="203c29" class="tk">CANCENABLE</a></td></tr>
<tr name="204" id="204">
<td><a id="l204" class='ln'>204</a></td><td></td></tr>
<tr name="205" id="205">
<td><a id="l205" class='ln'>205</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="206" id="206">
<td><a id="l206" class='ln'>206</a></td><td><span class="ct"> * FUNCTION :    ec_buffer_init                                            *</span></td></tr>
<tr name="207" id="207">
<td><a id="l207" class='ln'>207</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="208" id="208">
<td><a id="l208" class='ln'>208</a></td><td><span class="ct"> * DESCRIPTION : Initializes CAN buffer for CAN Controller                 *</span></td></tr>
<tr name="209" id="209">
<td><a id="l209" class='ln'>209</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="210" id="210">
<td><a id="l210" class='ln'>210</a></td><td><span class="ct"> * PARAMETERS :  -Module: FLEXCAN_A, FLEXCAN_B or FLEXCAN_C                *</span></td></tr>
<tr name="211" id="211">
<td><a id="l211" class='ln'>211</a></td><td><span class="ct"> *               -BufNum: buffer number                                    *</span></td></tr>
<tr name="212" id="212">
<td><a id="l212" class='ln'>212</a></td><td><span class="ct"> *               -IdType: standard or extended ID type                     *</span></td></tr>
<tr name="213" id="213">
<td><a id="l213" class='ln'>213</a></td><td><span class="ct"> *               -Id: CAN message ID                                       *</span></td></tr>
<tr name="214" id="214">
<td><a id="l214" class='ln'>214</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="215" id="215">
<td><a id="l215" class='ln'>215</a></td><td><span class="ct"> * RETURN :      None                                                      *</span></td></tr>
<tr name="216" id="216">
<td><a id="l216" class='ln'>216</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="217" id="217">
<td><a id="l217" class='ln'>217</a></td><td><span class="kw">void</span> <a id="217c6" class="tk">ec_buffer_init</a>(<a id="217c21" class="tk">uint8</a> <a id="217c27" class="tk">Module</a>,<a id="217c34" class="tk">uint8</a> <a id="217c40" class="tk">BufNum</a>,<a id="217c47" class="tk">uint8</a> <a id="217c53" class="tk">IdType</a>,<a id="217c60" class="tk">uint32</a> <a id="217c67" class="tk">Id</a>)</td></tr>
<tr name="218" id="218">
<td><a id="l218" class='ln'>218</a></td><td><span class="br">{</span></td></tr>
<tr name="219" id="219">
<td><a id="l219" class='ln'>219</a></td><td>  <a id="219c3" class="tk">FLEXCAN</a>(<a id="219c11" class="tk">Module</a>).<a id="219c19" class="tk">MCR</a>.<a id="219c23" class="tk">R</a> = 0x5000003F;  <span class="ct">/* 64 message buffers in use */</span></td></tr>
<tr name="220" id="220">
<td><a id="l220" class='ln'>220</a></td><td>  <span class="kw">if</span> ((<a id="220c8" class="tk">BufNum</a> <a id="220c15" class="tk">&lt;</a> 8)<a id="220c19" class="tk">||</a>(<a id="220c22" class="tk">BufNum</a> <a id="220c29" class="tk">&gt;</a> 15)) <span class="br">{</span></td></tr>
<tr name="221" id="221">
<td><a id="l221" class='ln'>221</a></td><td>    <span class="kw">if</span> (<a id="221c9" class="tk">IdType</a> <a id="221c16" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="222" id="222">
<td><a id="l222" class='ln'>222</a></td><td>      <a id="222c7" class="tk">FLEXCAN</a>(<a id="222c15" class="tk">Module</a>).<a id="222c23" class="tk">MB</a>[<a id="222c26" class="tk">BufNum</a>].<a id="222c34" class="tk">ID</a>.<a id="222c37" class="tk">B</a>.<a id="222c39" class="tk">ID_STD</a> = <a id="222c48" class="tk">Id</a>;</td></tr>
<tr name="223" id="223">
<td><a id="l223" class='ln'>223</a></td><td>      <a id="223c7" class="tk">FLEXCAN</a>(<a id="223c15" class="tk">Module</a>).<a id="223c23" class="tk">MB</a>[<a id="223c26" class="tk">BufNum</a>].<a id="223c34" class="tk">CS</a>.<a id="223c37" class="tk">B</a>.<a id="223c39" class="tk">IDE</a> = <a id="223c45" class="tk">MB_IDType_ST</a>;</td></tr>
<tr name="224" id="224">
<td><a id="l224" class='ln'>224</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="225" id="225">
<td><a id="l225" class='ln'>225</a></td><td>      <a id="225c7" class="tk">FLEXCAN</a>(<a id="225c15" class="tk">Module</a>).<a id="225c23" class="tk">MB</a>[<a id="225c26" class="tk">BufNum</a>].<a id="225c34" class="tk">ID</a>.<a id="225c37" class="tk">R</a> = <a id="225c41" class="tk">Id</a>;</td></tr>
<tr name="226" id="226">
<td><a id="l226" class='ln'>226</a></td><td>      <a id="226c7" class="tk">FLEXCAN</a>(<a id="226c15" class="tk">Module</a>).<a id="226c23" class="tk">MB</a>[<a id="226c26" class="tk">BufNum</a>].<a id="226c34" class="tk">CS</a>.<a id="226c37" class="tk">B</a>.<a id="226c39" class="tk">IDE</a> = <a id="226c45" class="tk">MB_IDType_EX</a>;</td></tr>
<tr name="227" id="227">
<td><a id="l227" class='ln'>227</a></td><td>    <span class="br">}</span></td></tr>
<tr name="228" id="228">
<td><a id="l228" class='ln'>228</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="229" id="229">
<td><a id="l229" class='ln'>229</a></td><td>  <span class="br">}</span></td></tr>
<tr name="230" id="230">
<td><a id="l230" class='ln'>230</a></td><td></td></tr>
<tr name="231" id="231">
<td><a id="l231" class='ln'>231</a></td><td>  <span class="kw">if</span> (<a id="231c7" class="tk">BufNum</a> <a id="231c14" class="tk">==</a> 14) <span class="br">{</span></td></tr>
<tr name="232" id="232">
<td><a id="l232" class='ln'>232</a></td><td>    <a id="232c5" class="tk">FLEXCAN</a>(<a id="232c13" class="tk">Module</a>).<a id="232c21" class="tk">RX14MASK</a>.<a id="232c30" class="tk">R</a> = 0x10000000;</td></tr>
<tr name="233" id="233">
<td><a id="l233" class='ln'>233</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="234" id="234">
<td><a id="l234" class='ln'>234</a></td><td>  <span class="br">}</span></td></tr>
<tr name="235" id="235">
<td><a id="l235" class='ln'>235</a></td><td></td></tr>
<tr name="236" id="236">
<td><a id="l236" class='ln'>236</a></td><td>  <a id="236c3" class="tk">FLEXCAN</a>(<a id="236c11" class="tk">Module</a>).<a id="236c19" class="tk">MCR</a>.<a id="236c23" class="tk">R</a> = <a id="236c27" class="tk">CAN_NORMAL_MODE</a><a id="236c42" class="tk">|</a><a id="236c43" class="tk">NUM_OF_ENABLED_MB</a>;<span class="ct">/* Normal mode */</span></td></tr>
<tr name="237" id="237">
<td><a id="l237" class='ln'>237</a></td><td>  <a id="237c3" class="tk">FLEXCAN</a>(<a id="237c11" class="tk">Module</a>).<a id="237c19" class="tk">MCR</a>.<a id="237c23" class="tk">B</a>.<a id="237c25" class="tk">HALT</a>= 0;</td></tr>
<tr name="238" id="238">
<td><a id="l238" class='ln'>238</a></td><td>                          <span class="ct">/* FlexCAN attempts to synchronize with the CAN bus */</span></td></tr>
<tr name="239" id="239">
<td><a id="l239" class='ln'>239</a></td><td><span class="br">}</span></td></tr>
<tr name="240" id="240">
<td><a id="l240" class='ln'>240</a></td><td></td></tr>
<tr name="241" id="241">
<td><a id="l241" class='ln'>241</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="242" id="242">
<td><a id="l242" class='ln'>242</a></td><td><span class="ct"> * FUNCTION :    ec_bufint_init                                            *</span></td></tr>
<tr name="243" id="243">
<td><a id="l243" class='ln'>243</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="244" id="244">
<td><a id="l244" class='ln'>244</a></td><td><span class="ct"> * DESCRIPTION : Initializes CAN buffer interrupts for CAN Controller      *</span></td></tr>
<tr name="245" id="245">
<td><a id="l245" class='ln'>245</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="246" id="246">
<td><a id="l246" class='ln'>246</a></td><td><span class="ct"> * PARAMETERS :  -Module: FLEXCAN_A, FLEXCAN_B or FLEXCAN_C                *</span></td></tr>
<tr name="247" id="247">
<td><a id="l247" class='ln'>247</a></td><td><span class="ct"> *               -BufNum: buffer number                                    *</span></td></tr>
<tr name="248" id="248">
<td><a id="l248" class='ln'>248</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="249" id="249">
<td><a id="l249" class='ln'>249</a></td><td><span class="ct"> * RETURN :      None                                                      *</span></td></tr>
<tr name="250" id="250">
<td><a id="l250" class='ln'>250</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="251" id="251">
<td><a id="l251" class='ln'>251</a></td><td><span class="kw">void</span> <a id="251c6" class="tk">ec_bufint_init</a>(<a id="251c21" class="tk">uint8</a> <a id="251c27" class="tk">Module</a>,<a id="251c34" class="tk">uint8</a> <a id="251c40" class="tk">BufNum</a>)</td></tr>
<tr name="252" id="252">
<td><a id="l252" class='ln'>252</a></td><td><span class="br">{</span></td></tr>
<tr name="253" id="253">
<td><a id="l253" class='ln'>253</a></td><td>  <a id="253c3" class="tk">FLEXCAN</a>(<a id="253c11" class="tk">Module</a>).<a id="253c19" class="tk">MCR</a>.<a id="253c23" class="tk">R</a> = 0x5000003F;  <span class="ct">/* 64 message buffers in use */</span></td></tr>
<tr name="254" id="254">
<td><a id="l254" class='ln'>254</a></td><td>  <a id="254c3" class="tk">FLEXCAN</a>(<a id="254c11" class="tk">Module</a>).<a id="254c19" class="tk">IMASK1</a>.<a id="254c26" class="tk">R</a> <a id="254c28" class="tk">|=</a> (0x1U <a id="254c37" class="tk">&lt;&lt;</a> <a id="254c40" class="tk">BufNum</a>);</td></tr>
<tr name="255" id="255">
<td><a id="l255" class='ln'>255</a></td><td>  <a id="255c3" class="tk">FLEXCAN</a>(<a id="255c11" class="tk">Module</a>).<a id="255c19" class="tk">MCR</a>.<a id="255c23" class="tk">R</a> = <a id="255c27" class="tk">CAN_NORMAL_MODE</a><a id="255c42" class="tk">|</a><a id="255c43" class="tk">NUM_OF_ENABLED_MB</a>;<span class="ct">/* Normal mode */</span></td></tr>
<tr name="256" id="256">
<td><a id="l256" class='ln'>256</a></td><td>  <a id="256c3" class="tk">FLEXCAN</a>(<a id="256c11" class="tk">Module</a>).<a id="256c19" class="tk">MCR</a>.<a id="256c23" class="tk">B</a>.<a id="256c25" class="tk">HALT</a> = 0;</td></tr>
<tr name="257" id="257">
<td><a id="l257" class='ln'>257</a></td><td>                          <span class="ct">/* FlexCAN attempts to synchronize with the CAN bus */</span></td></tr>
<tr name="258" id="258">
<td><a id="l258" class='ln'>258</a></td><td><span class="br">}</span></td></tr>
<tr name="259" id="259">
<td><a id="l259" class='ln'>259</a></td><td></td></tr>
<tr name="260" id="260">
<td><a id="l260" class='ln'>260</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="261" id="261">
<td><a id="l261" class='ln'>261</a></td><td><span class="ct"> * FUNCTION :    ec_can_receive                                            *</span></td></tr>
<tr name="262" id="262">
<td><a id="l262" class='ln'>262</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="263" id="263">
<td><a id="l263" class='ln'>263</a></td><td><span class="ct"> * DESCRIPTION : Receive CAN message and copy message to Rx_Buffer[]       *</span></td></tr>
<tr name="264" id="264">
<td><a id="l264" class='ln'>264</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="265" id="265">
<td><a id="l265" class='ln'>265</a></td><td><span class="ct"> * PARAMETERS :  -Module: FLEXCAN_0, FLEXCAN_1 or FLEXCAN_2                *</span></td></tr>
<tr name="266" id="266">
<td><a id="l266" class='ln'>266</a></td><td><span class="ct"> *               -BufNum: buffer number for receive                        *</span></td></tr>
<tr name="267" id="267">
<td><a id="l267" class='ln'>267</a></td><td><span class="ct"> *               -Rx_Buffer: a pointer pointing to the buffer used to      *</span></td></tr>
<tr name="268" id="268">
<td><a id="l268" class='ln'>268</a></td><td><span class="ct"> *                save the data received by CAN                            *</span></td></tr>
<tr name="269" id="269">
<td><a id="l269" class='ln'>269</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="270" id="270">
<td><a id="l270" class='ln'>270</a></td><td><span class="ct"> * RETURN :      -result: CAN_NOT_OK or CAN_OK                             *</span></td></tr>
<tr name="271" id="271">
<td><a id="l271" class='ln'>271</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="272" id="272">
<td><a id="l272" class='ln'>272</a></td><td><a id="272c1" class="tk">CAN_Return</a> <a id="272c12" class="tk">ec_can_receive</a>(<a id="272c27" class="tk">uint8</a> <a id="272c33" class="tk">Module</a>,<a id="272c40" class="tk">uint8</a> <a id="272c46" class="tk">BufNum</a>,<a id="272c53" class="tk">uint8</a> <a id="272c59" class="tk">Rx_Buffer</a>[])</td></tr>
<tr name="273" id="273">
<td><a id="l273" class='ln'>273</a></td><td><span class="br">{</span></td></tr>
<tr name="274" id="274">
<td><a id="l274" class='ln'>274</a></td><td>  <a id="274c3" class="tk">uint8</a> <a id="274c9" class="tk">DataNum</a>,<a id="274c17" class="tk">Code</a>,<a id="274c22" class="tk">Length</a>;</td></tr>
<tr name="275" id="275">
<td><a id="l275" class='ln'>275</a></td><td>  <a id="275c3" class="tk">uint16</a> <a id="275c10" class="tk">FrameTime</a>;</td></tr>
<tr name="276" id="276">
<td><a id="l276" class='ln'>276</a></td><td>  <a id="276c3" class="tk">uint32</a> <a id="276c10" class="tk">i</a>;</td></tr>
<tr name="277" id="277">
<td><a id="l277" class='ln'>277</a></td><td>  <a id="277c3" class="tk">CAN_Return</a> <a id="277c14" class="tk">result</a> = <a id="277c23" class="tk">CAN_NOT_OK</a>;</td></tr>
<tr name="278" id="278">
<td><a id="l278" class='ln'>278</a></td><td>  <span class="kw">if</span> (<a id="278c7" class="tk">BufNum</a><a id="278c13" class="tk">&lt;</a>32) <span class="br">{</span></td></tr>
<tr name="279" id="279">
<td><a id="l279" class='ln'>279</a></td><td>    <span class="kw">if</span> (((<a id="279c11" class="tk">FLEXCAN</a>(<a id="279c19" class="tk">Module</a>).<a id="279c27" class="tk">IFLAG1</a>.<a id="279c34" class="tk">R</a><a id="279c35" class="tk">&gt;&gt;</a><a id="279c37" class="tk">BufNum</a>)<a id="279c44" class="tk">&amp;</a>0x01) <a id="279c51" class="tk">==</a> 0x01) <span class="br">{</span></td></tr>
<tr name="280" id="280">
<td><a id="l280" class='ln'>280</a></td><td>      <a id="280c7" class="tk">Code</a> = (<a id="280c15" class="tk">uint8</a>)<a id="280c21" class="tk">FLEXCAN</a>(<a id="280c29" class="tk">Module</a>).<a id="280c37" class="tk">MB</a>[<a id="280c40" class="tk">BufNum</a>].<a id="280c48" class="tk">CS</a>.<a id="280c51" class="tk">B</a>.<a id="280c53" class="tk">CODE</a>;</td></tr>
<tr name="281" id="281">
<td><a id="l281" class='ln'>281</a></td><td>      <a id="281c7" class="tk">Length</a> = (<a id="281c17" class="tk">uint8</a>)<a id="281c23" class="tk">FLEXCAN</a>(<a id="281c31" class="tk">Module</a>).<a id="281c39" class="tk">MB</a>[<a id="281c42" class="tk">BufNum</a>].<a id="281c50" class="tk">CS</a>.<a id="281c53" class="tk">B</a>.<a id="281c55" class="tk">DLC</a>;</td></tr>
<tr name="282" id="282">
<td><a id="l282" class='ln'>282</a></td><td>      <a id="282c7" class="tk">FrameTime</a> = (<a id="282c20" class="tk">uint16</a>)<a id="282c27" class="tk">FLEXCAN</a>(<a id="282c35" class="tk">Module</a>).<a id="282c43" class="tk">MB</a>[<a id="282c46" class="tk">BufNum</a>].<a id="282c54" class="tk">CS</a>.<a id="282c57" class="tk">B</a>.<a id="282c59" class="tk">TIMESTAMP</a>;</td></tr>
<tr name="283" id="283">
<td><a id="l283" class='ln'>283</a></td><td>      <span class="kw">for</span> (<a id="283c12" class="tk">DataNum</a>=0; <a id="283c23" class="tk">DataNum</a><a id="283c30" class="tk">&lt;</a><a id="283c31" class="tk">FLEXCAN</a>(<a id="283c39" class="tk">Module</a>).<a id="283c47" class="tk">MB</a>[<a id="283c50" class="tk">BufNum</a>].<a id="283c58" class="tk">CS</a>.<a id="283c61" class="tk">B</a>.<a id="283c63" class="tk">DLC</a>; <a id="283c68" class="tk">DataNum</a><a id="283c75" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="284" id="284">
<td><a id="l284" class='ln'>284</a></td><td>        <a id="284c9" class="tk">Rx_Buffer</a>[<a id="284c19" class="tk">DataNum</a>] = (<a id="284c31" class="tk">uint8</a>)<a id="284c37" class="tk">FLEXCAN</a>(<a id="284c45" class="tk">Module</a>).<a id="284c53" class="tk">MB</a>[<a id="284c56" class="tk">BufNum</a>].<a id="284c64" class="tk">DATA</a>.<a id="284c69" class="tk">B</a>[<a id="284c71" class="tk">DataNum</a>];</td></tr>
<tr name="285" id="285">
<td><a id="l285" class='ln'>285</a></td><td>      <span class="br">}</span></td></tr>
<tr name="286" id="286">
<td><a id="l286" class='ln'>286</a></td><td></td></tr>
<tr name="287" id="287">
<td><a id="l287" class='ln'>287</a></td><td>      <a id="287c7" class="tk">ec_can_applrxindication</a>(<a id="287c31" class="tk">Module</a>,<a id="287c38" class="tk">BufNum</a>,<a id="287c45" class="tk">Rx_Buffer</a>);</td></tr>
<tr name="288" id="288">
<td><a id="l288" class='ln'>288</a></td><td>      <a id="288c7" class="tk">i</a> = <a id="288c11" class="tk">FLEXCAN</a>(<a id="288c19" class="tk">Module</a>).<a id="288c27" class="tk">TIMER</a>.<a id="288c33" class="tk">R</a>;</td></tr>
<tr name="289" id="289">
<td><a id="l289" class='ln'>289</a></td><td>      <a id="289c7" class="tk">FLEXCAN</a>(<a id="289c15" class="tk">Module</a>).<a id="289c23" class="tk">IFLAG1</a>.<a id="289c30" class="tk">R</a> = (<a id="289c35" class="tk">uint32</a>)0x01<a id="289c46" class="tk">&lt;&lt;</a><a id="289c48" class="tk">BufNum</a>;</td></tr>
<tr name="290" id="290">
<td><a id="l290" class='ln'>290</a></td><td>      <a id="290c7" class="tk">result</a> = <a id="290c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="291" id="291">
<td><a id="l291" class='ln'>291</a></td><td>    <span class="br">}</span></td></tr>
<tr name="292" id="292">
<td><a id="l292" class='ln'>292</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="293" id="293">
<td><a id="l293" class='ln'>293</a></td><td>    <span class="kw">if</span> (((<a id="293c11" class="tk">FLEXCAN</a>(<a id="293c19" class="tk">Module</a>).<a id="293c27" class="tk">IFLAG2</a>.<a id="293c34" class="tk">R</a><a id="293c35" class="tk">&gt;&gt;</a>(<a id="293c38" class="tk">BufNum</a><a id="293c44" class="tk">-</a>32))<a id="293c49" class="tk">&amp;</a>0x01) <a id="293c56" class="tk">==</a> 0x01) <span class="br">{</span></td></tr>
<tr name="294" id="294">
<td><a id="l294" class='ln'>294</a></td><td>      <a id="294c7" class="tk">Code</a> = (<a id="294c15" class="tk">uint8</a>)<a id="294c21" class="tk">FLEXCAN</a>(<a id="294c29" class="tk">Module</a>).<a id="294c37" class="tk">MB</a>[<a id="294c40" class="tk">BufNum</a>].<a id="294c48" class="tk">CS</a>.<a id="294c51" class="tk">B</a>.<a id="294c53" class="tk">CODE</a>;</td></tr>
<tr name="295" id="295">
<td><a id="l295" class='ln'>295</a></td><td>      <a id="295c7" class="tk">Length</a> = (<a id="295c17" class="tk">uint8</a>)<a id="295c23" class="tk">FLEXCAN</a>(<a id="295c31" class="tk">Module</a>).<a id="295c39" class="tk">MB</a>[<a id="295c42" class="tk">BufNum</a>].<a id="295c50" class="tk">CS</a>.<a id="295c53" class="tk">B</a>.<a id="295c55" class="tk">DLC</a>;</td></tr>
<tr name="296" id="296">
<td><a id="l296" class='ln'>296</a></td><td>      <a id="296c7" class="tk">FrameTime</a> = (<a id="296c20" class="tk">uint16</a>)<a id="296c27" class="tk">FLEXCAN</a>(<a id="296c35" class="tk">Module</a>).<a id="296c43" class="tk">MB</a>[<a id="296c46" class="tk">BufNum</a>].<a id="296c54" class="tk">CS</a>.<a id="296c57" class="tk">B</a>.<a id="296c59" class="tk">TIMESTAMP</a>;</td></tr>
<tr name="297" id="297">
<td><a id="l297" class='ln'>297</a></td><td>      <span class="kw">for</span> (<a id="297c12" class="tk">DataNum</a>=0; <a id="297c23" class="tk">DataNum</a><a id="297c30" class="tk">&lt;</a><a id="297c31" class="tk">FLEXCAN</a>(<a id="297c39" class="tk">Module</a>).<a id="297c47" class="tk">MB</a>[<a id="297c50" class="tk">BufNum</a>].<a id="297c58" class="tk">CS</a>.<a id="297c61" class="tk">B</a>.<a id="297c63" class="tk">DLC</a>; <a id="297c68" class="tk">DataNum</a><a id="297c75" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="298" id="298">
<td><a id="l298" class='ln'>298</a></td><td>        <a id="298c9" class="tk">Rx_Buffer</a>[<a id="298c19" class="tk">DataNum</a>] = (<a id="298c31" class="tk">uint8</a>)<a id="298c37" class="tk">FLEXCAN</a>(<a id="298c45" class="tk">Module</a>).<a id="298c53" class="tk">MB</a>[<a id="298c56" class="tk">BufNum</a>].<a id="298c64" class="tk">DATA</a>.<a id="298c69" class="tk">B</a>[<a id="298c71" class="tk">DataNum</a>];</td></tr>
<tr name="299" id="299">
<td><a id="l299" class='ln'>299</a></td><td>      <span class="br">}</span></td></tr>
<tr name="300" id="300">
<td><a id="l300" class='ln'>300</a></td><td></td></tr>
<tr name="301" id="301">
<td><a id="l301" class='ln'>301</a></td><td>      <a id="301c7" class="tk">ec_can_applrxindication</a>(<a id="301c31" class="tk">Module</a>,<a id="301c38" class="tk">BufNum</a>,<a id="301c45" class="tk">Rx_Buffer</a>);</td></tr>
<tr name="302" id="302">
<td><a id="l302" class='ln'>302</a></td><td>      <a id="302c7" class="tk">i</a> = <a id="302c11" class="tk">FLEXCAN</a>(<a id="302c19" class="tk">Module</a>).<a id="302c27" class="tk">TIMER</a>.<a id="302c33" class="tk">R</a>;</td></tr>
<tr name="303" id="303">
<td><a id="l303" class='ln'>303</a></td><td>      <a id="303c7" class="tk">FLEXCAN</a>(<a id="303c15" class="tk">Module</a>).<a id="303c23" class="tk">IFLAG2</a>.<a id="303c30" class="tk">R</a> = (<a id="303c35" class="tk">uint32</a>)0x01<a id="303c46" class="tk">&lt;&lt;</a>(<a id="303c49" class="tk">BufNum</a><a id="303c55" class="tk">-</a>32);</td></tr>
<tr name="304" id="304">
<td><a id="l304" class='ln'>304</a></td><td>      <a id="304c7" class="tk">result</a> = <a id="304c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="305" id="305">
<td><a id="l305" class='ln'>305</a></td><td>    <span class="br">}</span></td></tr>
<tr name="306" id="306">
<td><a id="l306" class='ln'>306</a></td><td>  <span class="br">}</span></td></tr>
<tr name="307" id="307">
<td><a id="l307" class='ln'>307</a></td><td></td></tr>
<tr name="308" id="308">
<td><a id="l308" class='ln'>308</a></td><td>  <span class="kw">return</span> <a id="308c10" class="tk">result</a>;</td></tr>
<tr name="309" id="309">
<td><a id="l309" class='ln'>309</a></td><td><span class="br">}</span></td></tr>
<tr name="310" id="310">
<td><a id="l310" class='ln'>310</a></td><td></td></tr>
<tr name="311" id="311">
<td><a id="l311" class='ln'>311</a></td><td><a id="311c1" class="tk">CAN_Return</a> <a id="311c12" class="tk">ec_can_receive_UDS</a>(<a id="311c31" class="tk">uint8</a> <a id="311c37" class="tk">Module</a>,<a id="311c44" class="tk">uint8</a> <a id="311c50" class="tk">BufNum</a>,<a id="311c57" class="tk">uint8</a> <a id="311c63" class="tk">Rx_Buffer</a>[], <a id="311c76" class="tk">uint8</a></td></tr>
<tr name="312" id="312">
<td><a id="l312" class='ln'>312</a></td><td>  <a id="312c3" class="tk">*</a><a id="312c4" class="tk">DLC</a>)</td></tr>
<tr name="313" id="313">
<td><a id="l313" class='ln'>313</a></td><td><span class="br">{</span></td></tr>
<tr name="314" id="314">
<td><a id="l314" class='ln'>314</a></td><td>  <a id="314c3" class="tk">uint8</a> <a id="314c9" class="tk">DataNum</a>,<a id="314c17" class="tk">Code</a>,<a id="314c22" class="tk">Length</a>;</td></tr>
<tr name="315" id="315">
<td><a id="l315" class='ln'>315</a></td><td>  <a id="315c3" class="tk">uint16</a> <a id="315c10" class="tk">FrameTime</a>;</td></tr>
<tr name="316" id="316">
<td><a id="l316" class='ln'>316</a></td><td>  <a id="316c3" class="tk">uint32</a> <a id="316c10" class="tk">i</a>;</td></tr>
<tr name="317" id="317">
<td><a id="l317" class='ln'>317</a></td><td>  <a id="317c3" class="tk">CAN_Return</a> <a id="317c14" class="tk">result</a> = <a id="317c23" class="tk">CAN_NOT_OK</a>;</td></tr>
<tr name="318" id="318">
<td><a id="l318" class='ln'>318</a></td><td>  <span class="kw">if</span> (<a id="318c7" class="tk">BufNum</a><a id="318c13" class="tk">&lt;</a>32) <span class="br">{</span></td></tr>
<tr name="319" id="319">
<td><a id="l319" class='ln'>319</a></td><td>    <span class="kw">if</span> (((<a id="319c11" class="tk">FLEXCAN</a>(<a id="319c19" class="tk">Module</a>).<a id="319c27" class="tk">IFLAG1</a>.<a id="319c34" class="tk">R</a><a id="319c35" class="tk">&gt;&gt;</a><a id="319c37" class="tk">BufNum</a>)<a id="319c44" class="tk">&amp;</a>0x01) <a id="319c51" class="tk">==</a> 0x01) <span class="br">{</span></td></tr>
<tr name="320" id="320">
<td><a id="l320" class='ln'>320</a></td><td>      <a id="320c7" class="tk">Code</a> = (<a id="320c15" class="tk">uint8</a>)<a id="320c21" class="tk">FLEXCAN</a>(<a id="320c29" class="tk">Module</a>).<a id="320c37" class="tk">MB</a>[<a id="320c40" class="tk">BufNum</a>].<a id="320c48" class="tk">CS</a>.<a id="320c51" class="tk">B</a>.<a id="320c53" class="tk">CODE</a>;</td></tr>
<tr name="321" id="321">
<td><a id="l321" class='ln'>321</a></td><td>      <a id="321c7" class="tk">*</a><a id="321c8" class="tk">DLC</a> = (<a id="321c15" class="tk">uint8</a>)<a id="321c21" class="tk">FLEXCAN</a>(<a id="321c29" class="tk">Module</a>).<a id="321c37" class="tk">MB</a>[<a id="321c40" class="tk">BufNum</a>].<a id="321c48" class="tk">CS</a>.<a id="321c51" class="tk">B</a>.<a id="321c53" class="tk">DLC</a>;</td></tr>
<tr name="322" id="322">
<td><a id="l322" class='ln'>322</a></td><td>      <a id="322c7" class="tk">FrameTime</a> = (<a id="322c20" class="tk">uint16</a>)<a id="322c27" class="tk">FLEXCAN</a>(<a id="322c35" class="tk">Module</a>).<a id="322c43" class="tk">MB</a>[<a id="322c46" class="tk">BufNum</a>].<a id="322c54" class="tk">CS</a>.<a id="322c57" class="tk">B</a>.<a id="322c59" class="tk">TIMESTAMP</a>;</td></tr>
<tr name="323" id="323">
<td><a id="l323" class='ln'>323</a></td><td>      <span class="kw">for</span> (<a id="323c12" class="tk">DataNum</a>=0; <a id="323c23" class="tk">DataNum</a><a id="323c30" class="tk">&lt;</a><a id="323c31" class="tk">FLEXCAN</a>(<a id="323c39" class="tk">Module</a>).<a id="323c47" class="tk">MB</a>[<a id="323c50" class="tk">BufNum</a>].<a id="323c58" class="tk">CS</a>.<a id="323c61" class="tk">B</a>.<a id="323c63" class="tk">DLC</a>; <a id="323c68" class="tk">DataNum</a><a id="323c75" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="324" id="324">
<td><a id="l324" class='ln'>324</a></td><td>        <a id="324c9" class="tk">Rx_Buffer</a>[<a id="324c19" class="tk">DataNum</a>] = (<a id="324c31" class="tk">uint8</a>)<a id="324c37" class="tk">FLEXCAN</a>(<a id="324c45" class="tk">Module</a>).<a id="324c53" class="tk">MB</a>[<a id="324c56" class="tk">BufNum</a>].<a id="324c64" class="tk">DATA</a>.<a id="324c69" class="tk">B</a>[<a id="324c71" class="tk">DataNum</a>];</td></tr>
<tr name="325" id="325">
<td><a id="l325" class='ln'>325</a></td><td>      <span class="br">}</span></td></tr>
<tr name="326" id="326">
<td><a id="l326" class='ln'>326</a></td><td></td></tr>
<tr name="327" id="327">
<td><a id="l327" class='ln'>327</a></td><td>      <a id="327c7" class="tk">ec_can_applrxindication</a>(<a id="327c31" class="tk">Module</a>,<a id="327c38" class="tk">BufNum</a>,<a id="327c45" class="tk">Rx_Buffer</a>);</td></tr>
<tr name="328" id="328">
<td><a id="l328" class='ln'>328</a></td><td>      <a id="328c7" class="tk">i</a> = <a id="328c11" class="tk">FLEXCAN</a>(<a id="328c19" class="tk">Module</a>).<a id="328c27" class="tk">TIMER</a>.<a id="328c33" class="tk">R</a>;</td></tr>
<tr name="329" id="329">
<td><a id="l329" class='ln'>329</a></td><td>      <a id="329c7" class="tk">FLEXCAN</a>(<a id="329c15" class="tk">Module</a>).<a id="329c23" class="tk">IFLAG1</a>.<a id="329c30" class="tk">R</a> = (<a id="329c35" class="tk">uint32</a>)0x01<a id="329c46" class="tk">&lt;&lt;</a><a id="329c48" class="tk">BufNum</a>;</td></tr>
<tr name="330" id="330">
<td><a id="l330" class='ln'>330</a></td><td>      <a id="330c7" class="tk">result</a> = <a id="330c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="331" id="331">
<td><a id="l331" class='ln'>331</a></td><td>    <span class="br">}</span></td></tr>
<tr name="332" id="332">
<td><a id="l332" class='ln'>332</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="333" id="333">
<td><a id="l333" class='ln'>333</a></td><td>    <span class="kw">if</span> (((<a id="333c11" class="tk">FLEXCAN</a>(<a id="333c19" class="tk">Module</a>).<a id="333c27" class="tk">IFLAG2</a>.<a id="333c34" class="tk">R</a><a id="333c35" class="tk">&gt;&gt;</a>(<a id="333c38" class="tk">BufNum</a><a id="333c44" class="tk">-</a>32))<a id="333c49" class="tk">&amp;</a>0x01) <a id="333c56" class="tk">==</a> 0x01) <span class="br">{</span></td></tr>
<tr name="334" id="334">
<td><a id="l334" class='ln'>334</a></td><td>      <a id="334c7" class="tk">Code</a> = (<a id="334c15" class="tk">uint8</a>)<a id="334c21" class="tk">FLEXCAN</a>(<a id="334c29" class="tk">Module</a>).<a id="334c37" class="tk">MB</a>[<a id="334c40" class="tk">BufNum</a>].<a id="334c48" class="tk">CS</a>.<a id="334c51" class="tk">B</a>.<a id="334c53" class="tk">CODE</a>;</td></tr>
<tr name="335" id="335">
<td><a id="l335" class='ln'>335</a></td><td>      <a id="335c7" class="tk">*</a><a id="335c8" class="tk">DLC</a> = (<a id="335c15" class="tk">uint8</a>)<a id="335c21" class="tk">FLEXCAN</a>(<a id="335c29" class="tk">Module</a>).<a id="335c37" class="tk">MB</a>[<a id="335c40" class="tk">BufNum</a>].<a id="335c48" class="tk">CS</a>.<a id="335c51" class="tk">B</a>.<a id="335c53" class="tk">DLC</a>;</td></tr>
<tr name="336" id="336">
<td><a id="l336" class='ln'>336</a></td><td>      <a id="336c7" class="tk">FrameTime</a> = (<a id="336c20" class="tk">uint16</a>)<a id="336c27" class="tk">FLEXCAN</a>(<a id="336c35" class="tk">Module</a>).<a id="336c43" class="tk">MB</a>[<a id="336c46" class="tk">BufNum</a>].<a id="336c54" class="tk">CS</a>.<a id="336c57" class="tk">B</a>.<a id="336c59" class="tk">TIMESTAMP</a>;</td></tr>
<tr name="337" id="337">
<td><a id="l337" class='ln'>337</a></td><td>      <span class="kw">for</span> (<a id="337c12" class="tk">DataNum</a>=0; <a id="337c23" class="tk">DataNum</a><a id="337c30" class="tk">&lt;</a><a id="337c31" class="tk">FLEXCAN</a>(<a id="337c39" class="tk">Module</a>).<a id="337c47" class="tk">MB</a>[<a id="337c50" class="tk">BufNum</a>].<a id="337c58" class="tk">CS</a>.<a id="337c61" class="tk">B</a>.<a id="337c63" class="tk">DLC</a>; <a id="337c68" class="tk">DataNum</a><a id="337c75" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="338" id="338">
<td><a id="l338" class='ln'>338</a></td><td>        <a id="338c9" class="tk">Rx_Buffer</a>[<a id="338c19" class="tk">DataNum</a>] = (<a id="338c31" class="tk">uint8</a>)<a id="338c37" class="tk">FLEXCAN</a>(<a id="338c45" class="tk">Module</a>).<a id="338c53" class="tk">MB</a>[<a id="338c56" class="tk">BufNum</a>].<a id="338c64" class="tk">DATA</a>.<a id="338c69" class="tk">B</a>[<a id="338c71" class="tk">DataNum</a>];</td></tr>
<tr name="339" id="339">
<td><a id="l339" class='ln'>339</a></td><td>      <span class="br">}</span></td></tr>
<tr name="340" id="340">
<td><a id="l340" class='ln'>340</a></td><td></td></tr>
<tr name="341" id="341">
<td><a id="l341" class='ln'>341</a></td><td>      <a id="341c7" class="tk">ec_can_applrxindication</a>(<a id="341c31" class="tk">Module</a>,<a id="341c38" class="tk">BufNum</a>,<a id="341c45" class="tk">Rx_Buffer</a>);</td></tr>
<tr name="342" id="342">
<td><a id="l342" class='ln'>342</a></td><td>      <a id="342c7" class="tk">i</a> = <a id="342c11" class="tk">FLEXCAN</a>(<a id="342c19" class="tk">Module</a>).<a id="342c27" class="tk">TIMER</a>.<a id="342c33" class="tk">R</a>;</td></tr>
<tr name="343" id="343">
<td><a id="l343" class='ln'>343</a></td><td>      <a id="343c7" class="tk">FLEXCAN</a>(<a id="343c15" class="tk">Module</a>).<a id="343c23" class="tk">IFLAG2</a>.<a id="343c30" class="tk">R</a> = (<a id="343c35" class="tk">uint32</a>)0x01<a id="343c46" class="tk">&lt;&lt;</a>(<a id="343c49" class="tk">BufNum</a><a id="343c55" class="tk">-</a>32);</td></tr>
<tr name="344" id="344">
<td><a id="l344" class='ln'>344</a></td><td>      <a id="344c7" class="tk">result</a> = <a id="344c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="345" id="345">
<td><a id="l345" class='ln'>345</a></td><td>    <span class="br">}</span></td></tr>
<tr name="346" id="346">
<td><a id="l346" class='ln'>346</a></td><td>  <span class="br">}</span></td></tr>
<tr name="347" id="347">
<td><a id="l347" class='ln'>347</a></td><td></td></tr>
<tr name="348" id="348">
<td><a id="l348" class='ln'>348</a></td><td>  <span class="kw">return</span> <a id="348c10" class="tk">result</a>;</td></tr>
<tr name="349" id="349">
<td><a id="l349" class='ln'>349</a></td><td><span class="br">}</span></td></tr>
<tr name="350" id="350">
<td><a id="l350" class='ln'>350</a></td><td></td></tr>
<tr name="351" id="351">
<td><a id="l351" class='ln'>351</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="352" id="352">
<td><a id="l352" class='ln'>352</a></td><td><span class="ct"> * FUNCTION :    ec_can_receiveall                                         *</span></td></tr>
<tr name="353" id="353">
<td><a id="l353" class='ln'>353</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="354" id="354">
<td><a id="l354" class='ln'>354</a></td><td><span class="ct"> * DESCRIPTION : Receive CAN message and copy message to Rx_Buffer[]       *</span></td></tr>
<tr name="355" id="355">
<td><a id="l355" class='ln'>355</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="356" id="356">
<td><a id="l356" class='ln'>356</a></td><td><span class="ct"> * PARAMETERS :  -Module: FLEXCAN_0, FLEXCAN_1 or FLEXCAN_2                *</span></td></tr>
<tr name="357" id="357">
<td><a id="l357" class='ln'>357</a></td><td><span class="ct"> *               -*Id: CAN message ID                                      *</span></td></tr>
<tr name="358" id="358">
<td><a id="l358" class='ln'>358</a></td><td><span class="ct"> *               -*Dlc: CAN message length                                 *</span></td></tr>
<tr name="359" id="359">
<td><a id="l359" class='ln'>359</a></td><td><span class="ct"> *               -Rx_Buffer: a pointer pointing to the buffer used to      *</span></td></tr>
<tr name="360" id="360">
<td><a id="l360" class='ln'>360</a></td><td><span class="ct"> *                save the data received by CAN                            *</span></td></tr>
<tr name="361" id="361">
<td><a id="l361" class='ln'>361</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="362" id="362">
<td><a id="l362" class='ln'>362</a></td><td><span class="ct"> * RETURN :      -result: CAN_NOT_OK or CAN_OK                             *</span></td></tr>
<tr name="363" id="363">
<td><a id="l363" class='ln'>363</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="364" id="364">
<td><a id="l364" class='ln'>364</a></td><td><a id="364c1" class="tk">CAN_Return</a> <a id="364c12" class="tk">ec_can_receiveall</a>(<a id="364c30" class="tk">uint8</a> <a id="364c36" class="tk">Module</a>,<a id="364c43" class="tk">uint32</a> <a id="364c50" class="tk">*</a><a id="364c51" class="tk">Id</a>,<a id="364c54" class="tk">uint8</a> <a id="364c60" class="tk">*</a><a id="364c61" class="tk">Dlc</a>,<a id="364c65" class="tk">uint8</a> <a id="364c71" class="tk">Rx_Buffer</a>[])</td></tr>
<tr name="365" id="365">
<td><a id="l365" class='ln'>365</a></td><td><span class="br">{</span></td></tr>
<tr name="366" id="366">
<td><a id="l366" class='ln'>366</a></td><td>  <a id="366c3" class="tk">uint8</a> <a id="366c9" class="tk">DataNum</a>,<a id="366c17" class="tk">Code</a>;</td></tr>
<tr name="367" id="367">
<td><a id="l367" class='ln'>367</a></td><td>  <a id="367c3" class="tk">uint16</a> <a id="367c10" class="tk">FrameTime</a>;</td></tr>
<tr name="368" id="368">
<td><a id="l368" class='ln'>368</a></td><td>  <a id="368c3" class="tk">uint32</a> <a id="368c10" class="tk">i</a>;</td></tr>
<tr name="369" id="369">
<td><a id="l369" class='ln'>369</a></td><td>  <a id="369c3" class="tk">CAN_Return</a> <a id="369c14" class="tk">result</a> = <a id="369c23" class="tk">CAN_NOT_OK</a>;</td></tr>
<tr name="370" id="370">
<td><a id="l370" class='ln'>370</a></td><td>  <span class="kw">if</span> (((<a id="370c9" class="tk">FLEXCAN</a>(<a id="370c17" class="tk">Module</a>).<a id="370c25" class="tk">IFLAG1</a>.<a id="370c32" class="tk">R</a><a id="370c33" class="tk">&gt;&gt;</a>14)<a id="370c38" class="tk">&amp;</a>0x01) <a id="370c45" class="tk">==</a> 0x01) <span class="br">{</span></td></tr>
<tr name="371" id="371">
<td><a id="l371" class='ln'>371</a></td><td>    <a id="371c5" class="tk">Code</a> = (<a id="371c13" class="tk">uint8</a>)<a id="371c19" class="tk">FLEXCAN</a>(<a id="371c27" class="tk">Module</a>).<a id="371c35" class="tk">MB</a>[14].<a id="371c42" class="tk">CS</a>.<a id="371c45" class="tk">B</a>.<a id="371c47" class="tk">CODE</a>;</td></tr>
<tr name="372" id="372">
<td><a id="l372" class='ln'>372</a></td><td>    <a id="372c5" class="tk">*</a><a id="372c6" class="tk">Dlc</a> = (<a id="372c13" class="tk">uint8</a>)<a id="372c19" class="tk">FLEXCAN</a>(<a id="372c27" class="tk">Module</a>).<a id="372c35" class="tk">MB</a>[14].<a id="372c42" class="tk">CS</a>.<a id="372c45" class="tk">B</a>.<a id="372c47" class="tk">DLC</a>;</td></tr>
<tr name="373" id="373">
<td><a id="l373" class='ln'>373</a></td><td>    <span class="kw">if</span> (<a id="373c9" class="tk">FLEXCAN</a>(<a id="373c17" class="tk">Module</a>).<a id="373c25" class="tk">MB</a>[14].<a id="373c32" class="tk">CS</a>.<a id="373c35" class="tk">B</a>.<a id="373c37" class="tk">IDE</a> <a id="373c41" class="tk">==</a> <a id="373c44" class="tk">MB_IDType_EX</a>) <span class="br">{</span></td></tr>
<tr name="374" id="374">
<td><a id="l374" class='ln'>374</a></td><td>      <a id="374c7" class="tk">*</a><a id="374c8" class="tk">Id</a> = (<a id="374c14" class="tk">uint32</a>)<a id="374c21" class="tk">FLEXCAN</a>(<a id="374c29" class="tk">Module</a>).<a id="374c37" class="tk">MB</a>[14].<a id="374c44" class="tk">ID</a>.<a id="374c47" class="tk">R</a>;</td></tr>
<tr name="375" id="375">
<td><a id="l375" class='ln'>375</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="376" id="376">
<td><a id="l376" class='ln'>376</a></td><td>      <a id="376c7" class="tk">*</a><a id="376c8" class="tk">Id</a> = (<a id="376c14" class="tk">uint32</a>)<a id="376c21" class="tk">FLEXCAN</a>(<a id="376c29" class="tk">Module</a>).<a id="376c37" class="tk">MB</a>[14].<a id="376c44" class="tk">ID</a>.<a id="376c47" class="tk">B</a>.<a id="376c49" class="tk">ID_STD</a>;</td></tr>
<tr name="377" id="377">
<td><a id="l377" class='ln'>377</a></td><td>    <span class="br">}</span></td></tr>
<tr name="378" id="378">
<td><a id="l378" class='ln'>378</a></td><td></td></tr>
<tr name="379" id="379">
<td><a id="l379" class='ln'>379</a></td><td>    <a id="379c5" class="tk">FrameTime</a> = (<a id="379c18" class="tk">uint16</a>)<a id="379c25" class="tk">FLEXCAN</a>(<a id="379c33" class="tk">Module</a>).<a id="379c41" class="tk">MB</a>[14].<a id="379c48" class="tk">CS</a>.<a id="379c51" class="tk">B</a>.<a id="379c53" class="tk">TIMESTAMP</a>;</td></tr>
<tr name="380" id="380">
<td><a id="l380" class='ln'>380</a></td><td>    <span class="kw">for</span> (<a id="380c10" class="tk">DataNum</a>=0; <a id="380c21" class="tk">DataNum</a><a id="380c28" class="tk">&lt;</a><a id="380c29" class="tk">FLEXCAN</a>(<a id="380c37" class="tk">Module</a>).<a id="380c45" class="tk">MB</a>[14].<a id="380c52" class="tk">CS</a>.<a id="380c55" class="tk">B</a>.<a id="380c57" class="tk">DLC</a>; <a id="380c62" class="tk">DataNum</a><a id="380c69" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="381" id="381">
<td><a id="l381" class='ln'>381</a></td><td>      <a id="381c7" class="tk">Rx_Buffer</a>[<a id="381c17" class="tk">DataNum</a>] = (<a id="381c29" class="tk">uint8</a>)<a id="381c35" class="tk">FLEXCAN</a>(<a id="381c43" class="tk">Module</a>).<a id="381c51" class="tk">MB</a>[14].<a id="381c58" class="tk">DATA</a>.<a id="381c63" class="tk">B</a>[<a id="381c65" class="tk">DataNum</a>];</td></tr>
<tr name="382" id="382">
<td><a id="l382" class='ln'>382</a></td><td>    <span class="br">}</span></td></tr>
<tr name="383" id="383">
<td><a id="l383" class='ln'>383</a></td><td></td></tr>
<tr name="384" id="384">
<td><a id="l384" class='ln'>384</a></td><td>    <a id="384c5" class="tk">i</a> = <a id="384c9" class="tk">FLEXCAN</a>(<a id="384c17" class="tk">Module</a>).<a id="384c25" class="tk">TIMER</a>.<a id="384c31" class="tk">R</a>;</td></tr>
<tr name="385" id="385">
<td><a id="l385" class='ln'>385</a></td><td>    <a id="385c5" class="tk">FLEXCAN</a>(<a id="385c13" class="tk">Module</a>).<a id="385c21" class="tk">IFLAG1</a>.<a id="385c28" class="tk">R</a> = (<a id="385c33" class="tk">uint32</a>)0x01<a id="385c44" class="tk">&lt;&lt;</a>14;</td></tr>
<tr name="386" id="386">
<td><a id="l386" class='ln'>386</a></td><td>    <a id="386c5" class="tk">result</a> = <a id="386c14" class="tk">CAN_OK</a>;</td></tr>
<tr name="387" id="387">
<td><a id="l387" class='ln'>387</a></td><td>  <span class="br">}</span></td></tr>
<tr name="388" id="388">
<td><a id="l388" class='ln'>388</a></td><td></td></tr>
<tr name="389" id="389">
<td><a id="l389" class='ln'>389</a></td><td>  <span class="kw">return</span> <a id="389c10" class="tk">result</a>;</td></tr>
<tr name="390" id="390">
<td><a id="l390" class='ln'>390</a></td><td><span class="br">}</span></td></tr>
<tr name="391" id="391">
<td><a id="l391" class='ln'>391</a></td><td></td></tr>
<tr name="392" id="392">
<td><a id="l392" class='ln'>392</a></td><td><span class="ct">/**************************************************************************</span></td></tr>
<tr name="393" id="393">
<td><a id="l393" class='ln'>393</a></td><td><span class="ct"> * FUNCTION :    ec_can_transmit                                           *</span></td></tr>
<tr name="394" id="394">
<td><a id="l394" class='ln'>394</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="395" id="395">
<td><a id="l395" class='ln'>395</a></td><td><span class="ct"> * DESCRIPTION : Copy CAN Tx_Buffer to CAN Message Buffer and then         *</span></td></tr>
<tr name="396" id="396">
<td><a id="l396" class='ln'>396</a></td><td><span class="ct"> *               transmit message to CAN bus                               *</span></td></tr>
<tr name="397" id="397">
<td><a id="l397" class='ln'>397</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="398" id="398">
<td><a id="l398" class='ln'>398</a></td><td><span class="ct"> * PARAMETERS :  -Module: FLEXCAN_0, FLEXCAN_1 or FLEXCAN_2                *</span></td></tr>
<tr name="399" id="399">
<td><a id="l399" class='ln'>399</a></td><td><span class="ct"> *               -BufNum: buffer number for transmit                       *</span></td></tr>
<tr name="400" id="400">
<td><a id="l400" class='ln'>400</a></td><td><span class="ct"> *               -IdType: 0 means standard format;1 means entend format    *</span></td></tr>
<tr name="401" id="401">
<td><a id="l401" class='ln'>401</a></td><td><span class="ct"> *               -Id: the message ID to be transmitted                     *</span></td></tr>
<tr name="402" id="402">
<td><a id="l402" class='ln'>402</a></td><td><span class="ct"> *               -DataLength: data length of the frame data                *</span></td></tr>
<tr name="403" id="403">
<td><a id="l403" class='ln'>403</a></td><td><span class="ct"> *               -Tx_Buffer: the data array to be transmitted              *</span></td></tr>
<tr name="404" id="404">
<td><a id="l404" class='ln'>404</a></td><td><span class="ct"> *                                                                         *</span></td></tr>
<tr name="405" id="405">
<td><a id="l405" class='ln'>405</a></td><td><span class="ct"> * RETURN :      -result: CAN_BUSY or CAN_OK.                              *</span></td></tr>
<tr name="406" id="406">
<td><a id="l406" class='ln'>406</a></td><td><span class="ct"> ***************************************************************************/</span></td></tr>
<tr name="407" id="407">
<td><a id="l407" class='ln'>407</a></td><td><a id="407c1" class="tk">CAN_Return</a> <a id="407c12" class="tk">ec_can_transmit</a>(<a id="407c28" class="tk">uint8</a> <a id="407c34" class="tk">Module</a>,<a id="407c41" class="tk">uint8</a> <a id="407c47" class="tk">BufNum</a>,<a id="407c54" class="tk">uint8</a> <a id="407c60" class="tk">IdType</a>,<a id="407c67" class="tk">uint32</a> <a id="407c74" class="tk">Id</a>,</td></tr>
<tr name="408" id="408">
<td><a id="l408" class='ln'>408</a></td><td>  <a id="408c3" class="tk">uint8</a> <a id="408c9" class="tk">DataLength</a>,<a id="408c20" class="tk">uint8</a> <a id="408c26" class="tk">Tx_Buffer</a>[])</td></tr>
<tr name="409" id="409">
<td><a id="l409" class='ln'>409</a></td><td><span class="br">{</span></td></tr>
<tr name="410" id="410">
<td><a id="l410" class='ln'>410</a></td><td>  <a id="410c3" class="tk">uint8</a> <a id="410c9" class="tk">i</a>;</td></tr>
<tr name="411" id="411">
<td><a id="l411" class='ln'>411</a></td><td>  <a id="411c3" class="tk">CAN_Return</a> <a id="411c14" class="tk">result</a> = <a id="411c23" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="412" id="412">
<td><a id="l412" class='ln'>412</a></td><td>  <span class="kw">if</span> (<a id="412c7" class="tk">BufNum</a><a id="412c13" class="tk">&lt;</a>8)</td></tr>
<tr name="413" id="413">
<td><a id="l413" class='ln'>413</a></td><td>    <a id="413c5" class="tk">BufNum</a> = 8;</td></tr>
<tr name="414" id="414">
<td><a id="l414" class='ln'>414</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> ((<a id="414c13" class="tk">BufNum</a><a id="414c19" class="tk">&gt;</a>15)<a id="414c23" class="tk">&amp;</a>(<a id="414c25" class="tk">BufNum</a><a id="414c31" class="tk">&lt;</a>56))</td></tr>
<tr name="415" id="415">
<td><a id="l415" class='ln'>415</a></td><td>    <a id="415c5" class="tk">BufNum</a> = 15;</td></tr>
<tr name="416" id="416">
<td><a id="l416" class='ln'>416</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> (<a id="416c12" class="tk">BufNum</a><a id="416c18" class="tk">&gt;</a>63)</td></tr>
<tr name="417" id="417">
<td><a id="l417" class='ln'>417</a></td><td>    <a id="417c5" class="tk">BufNum</a> = 63;</td></tr>
<tr name="418" id="418">
<td><a id="l418" class='ln'>418</a></td><td>  <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="419" id="419">
<td><a id="l419" class='ln'>419</a></td><td>    <span class="kw">if</span> (<a id="419c9" class="tk">FLEXCAN</a>(<a id="419c17" class="tk">Module</a>).<a id="419c25" class="tk">MB</a>[<a id="419c28" class="tk">BufNum</a>].<a id="419c36" class="tk">CS</a>.<a id="419c39" class="tk">B</a>.<a id="419c41" class="tk">CODE</a> <a id="419c46" class="tk">==</a> <a id="419c49" class="tk">TX_MB_CODE_TRANSMIT</a>) <span class="br">{</span></td></tr>
<tr name="420" id="420">
<td><a id="l420" class='ln'>420</a></td><td>      <a id="420c7" class="tk">result</a> = <a id="420c16" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="421" id="421">
<td><a id="l421" class='ln'>421</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="422" id="422">
<td><a id="l422" class='ln'>422</a></td><td>      <span class="kw">if</span> (<a id="422c11" class="tk">IdType</a> <a id="422c18" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="423" id="423">
<td><a id="l423" class='ln'>423</a></td><td>        <a id="423c9" class="tk">FLEXCAN</a>(<a id="423c17" class="tk">Module</a>).<a id="423c25" class="tk">MB</a>[<a id="423c28" class="tk">BufNum</a>].<a id="423c36" class="tk">CS</a>.<a id="423c39" class="tk">B</a>.<a id="423c41" class="tk">IDE</a> = <a id="423c47" class="tk">MB_IDType_ST</a>;</td></tr>
<tr name="424" id="424">
<td><a id="l424" class='ln'>424</a></td><td>        <a id="424c9" class="tk">FLEXCAN</a>(<a id="424c17" class="tk">Module</a>).<a id="424c25" class="tk">MB</a>[<a id="424c28" class="tk">BufNum</a>].<a id="424c36" class="tk">ID</a>.<a id="424c39" class="tk">B</a>.<a id="424c41" class="tk">ID_STD</a> = <a id="424c50" class="tk">Id</a>;</td></tr>
<tr name="425" id="425">
<td><a id="l425" class='ln'>425</a></td><td>        <a id="425c9" class="tk">FLEXCAN</a>(<a id="425c17" class="tk">Module</a>).<a id="425c25" class="tk">MB</a>[<a id="425c28" class="tk">BufNum</a>].<a id="425c36" class="tk">CS</a>.<a id="425c39" class="tk">B</a>.<a id="425c41" class="tk">SRR</a> = 0;</td></tr>
<tr name="426" id="426">
<td><a id="l426" class='ln'>426</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="427" id="427">
<td><a id="l427" class='ln'>427</a></td><td>        <a id="427c9" class="tk">FLEXCAN</a>(<a id="427c17" class="tk">Module</a>).<a id="427c25" class="tk">MB</a>[<a id="427c28" class="tk">BufNum</a>].<a id="427c36" class="tk">CS</a>.<a id="427c39" class="tk">B</a>.<a id="427c41" class="tk">IDE</a> = <a id="427c47" class="tk">MB_IDType_EX</a>;</td></tr>
<tr name="428" id="428">
<td><a id="l428" class='ln'>428</a></td><td>        <a id="428c9" class="tk">FLEXCAN</a>(<a id="428c17" class="tk">Module</a>).<a id="428c25" class="tk">MB</a>[<a id="428c28" class="tk">BufNum</a>].<a id="428c36" class="tk">ID</a>.<a id="428c39" class="tk">R</a> = (<a id="428c44" class="tk">uint32</a>)(<a id="428c52" class="tk">Id</a><a id="428c54" class="tk">&amp;</a>0x1FFFFFFF);</td></tr>
<tr name="429" id="429">
<td><a id="l429" class='ln'>429</a></td><td>        <a id="429c9" class="tk">FLEXCAN</a>(<a id="429c17" class="tk">Module</a>).<a id="429c25" class="tk">MB</a>[<a id="429c28" class="tk">BufNum</a>].<a id="429c36" class="tk">CS</a>.<a id="429c39" class="tk">B</a>.<a id="429c41" class="tk">SRR</a> = 1;</td></tr>
<tr name="430" id="430">
<td><a id="l430" class='ln'>430</a></td><td>      <span class="br">}</span></td></tr>
<tr name="431" id="431">
<td><a id="l431" class='ln'>431</a></td><td></td></tr>
<tr name="432" id="432">
<td><a id="l432" class='ln'>432</a></td><td>      <a id="432c7" class="tk">FLEXCAN</a>(<a id="432c15" class="tk">Module</a>).<a id="432c23" class="tk">MB</a>[<a id="432c26" class="tk">BufNum</a>].<a id="432c34" class="tk">CS</a>.<a id="432c37" class="tk">B</a>.<a id="432c39" class="tk">RTR</a> = 0;</td></tr>
<tr name="433" id="433">
<td><a id="l433" class='ln'>433</a></td><td>      <span class="kw">for</span> (<a id="433c12" class="tk">i</a>=0; <a id="433c17" class="tk">i</a><a id="433c18" class="tk">&lt;</a><a id="433c19" class="tk">DataLength</a>; <a id="433c31" class="tk">i</a><a id="433c32" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="434" id="434">
<td><a id="l434" class='ln'>434</a></td><td>        <a id="434c9" class="tk">FLEXCAN</a>(<a id="434c17" class="tk">Module</a>).<a id="434c25" class="tk">MB</a>[<a id="434c28" class="tk">BufNum</a>].<a id="434c36" class="tk">DATA</a>.<a id="434c41" class="tk">B</a>[<a id="434c43" class="tk">i</a>] = <a id="434c48" class="tk">Tx_Buffer</a>[<a id="434c58" class="tk">i</a>];</td></tr>
<tr name="435" id="435">
<td><a id="l435" class='ln'>435</a></td><td>      <span class="br">}</span></td></tr>
<tr name="436" id="436">
<td><a id="l436" class='ln'>436</a></td><td></td></tr>
<tr name="437" id="437">
<td><a id="l437" class='ln'>437</a></td><td>      <a id="437c7" class="tk">FLEXCAN</a>(<a id="437c15" class="tk">Module</a>).<a id="437c23" class="tk">MB</a>[<a id="437c26" class="tk">BufNum</a>].<a id="437c34" class="tk">CS</a>.<a id="437c37" class="tk">B</a>.<a id="437c39" class="tk">DLC</a> = <a id="437c45" class="tk">DataLength</a>;</td></tr>
<tr name="438" id="438">
<td><a id="l438" class='ln'>438</a></td><td>      <a id="438c7" class="tk">FLEXCAN</a>(<a id="438c15" class="tk">Module</a>).<a id="438c23" class="tk">MB</a>[<a id="438c26" class="tk">BufNum</a>].<a id="438c34" class="tk">CS</a>.<a id="438c37" class="tk">B</a>.<a id="438c39" class="tk">CODE</a> = <a id="438c46" class="tk">TX_MB_CODE_TRANSMIT</a>;</td></tr>
<tr name="439" id="439">
<td><a id="l439" class='ln'>439</a></td><td>      <a id="439c7" class="tk">result</a> = <a id="439c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="440" id="440">
<td><a id="l440" class='ln'>440</a></td><td>      <a id="440c7" class="tk">ec_can_appltxconfirmation</a>(<a id="440c33" class="tk">Module</a>,<a id="440c40" class="tk">BufNum</a>);</td></tr>
<tr name="441" id="441">
<td><a id="l441" class='ln'>441</a></td><td>    <span class="br">}</span></td></tr>
<tr name="442" id="442">
<td><a id="l442" class='ln'>442</a></td><td>  <span class="br">}</span></td></tr>
<tr name="443" id="443">
<td><a id="l443" class='ln'>443</a></td><td></td></tr>
<tr name="444" id="444">
<td><a id="l444" class='ln'>444</a></td><td>  <span class="kw">return</span>(<a id="444c10" class="tk">result</a>);</td></tr>
<tr name="445" id="445">
<td><a id="l445" class='ln'>445</a></td><td><span class="br">}</span></td></tr>
<tr name="446" id="446">
<td><a id="l446" class='ln'>446</a></td><td></td></tr>
<tr name="447" id="447">
<td><a id="l447" class='ln'>447</a></td><td><a id="447c1" class="tk">CAN_Return</a> <a id="447c12" class="tk">ec_can_transmitnew</a>(<a id="447c31" class="tk">uint8</a> <a id="447c37" class="tk">Module</a>,<a id="447c44" class="tk">uint8</a> <a id="447c50" class="tk">BufNum</a>,<a id="447c57" class="tk">uint8</a> <a id="447c63" class="tk">IdType</a>,<a id="447c70" class="tk">uint32</a> <a id="447c77" class="tk">Id</a>,</td></tr>
<tr name="448" id="448">
<td><a id="l448" class='ln'>448</a></td><td>  <a id="448c3" class="tk">uint8</a> <a id="448c9" class="tk">DataLength</a>,<a id="448c20" class="tk">uint8</a> <a id="448c26" class="tk">Tx_Buffer</a>[])</td></tr>
<tr name="449" id="449">
<td><a id="l449" class='ln'>449</a></td><td><span class="br">{</span></td></tr>
<tr name="450" id="450">
<td><a id="l450" class='ln'>450</a></td><td>  <a id="450c3" class="tk">uint8</a> <a id="450c9" class="tk">i</a>;</td></tr>
<tr name="451" id="451">
<td><a id="l451" class='ln'>451</a></td><td>  <a id="451c3" class="tk">CAN_Return</a> <a id="451c14" class="tk">result</a> = <a id="451c23" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="452" id="452">
<td><a id="l452" class='ln'>452</a></td><td>  <span class="kw">if</span> (<a id="452c7" class="tk">BufNum</a><a id="452c13" class="tk">&lt;</a>8)</td></tr>
<tr name="453" id="453">
<td><a id="l453" class='ln'>453</a></td><td>    <a id="453c5" class="tk">BufNum</a> = 8;</td></tr>
<tr name="454" id="454">
<td><a id="l454" class='ln'>454</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> ((<a id="454c13" class="tk">BufNum</a><a id="454c19" class="tk">&gt;</a>15)<a id="454c23" class="tk">&amp;</a>(<a id="454c25" class="tk">BufNum</a><a id="454c31" class="tk">&lt;</a>40))</td></tr>
<tr name="455" id="455">
<td><a id="l455" class='ln'>455</a></td><td>    <a id="455c5" class="tk">BufNum</a> = 15;</td></tr>
<tr name="456" id="456">
<td><a id="l456" class='ln'>456</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> (<a id="456c12" class="tk">BufNum</a><a id="456c18" class="tk">&gt;</a>63)</td></tr>
<tr name="457" id="457">
<td><a id="l457" class='ln'>457</a></td><td>    <a id="457c5" class="tk">BufNum</a> = 63;</td></tr>
<tr name="458" id="458">
<td><a id="l458" class='ln'>458</a></td><td>  <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="459" id="459">
<td><a id="l459" class='ln'>459</a></td><td>    <span class="kw">if</span> (<a id="459c9" class="tk">FLEXCAN</a>(<a id="459c17" class="tk">Module</a>).<a id="459c25" class="tk">MB</a>[<a id="459c28" class="tk">BufNum</a>].<a id="459c36" class="tk">CS</a>.<a id="459c39" class="tk">B</a>.<a id="459c41" class="tk">CODE</a> <a id="459c46" class="tk">==</a> <a id="459c49" class="tk">TX_MB_CODE_TRANSMIT</a>) <span class="br">{</span></td></tr>
<tr name="460" id="460">
<td><a id="l460" class='ln'>460</a></td><td>      <a id="460c7" class="tk">result</a> = <a id="460c16" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="461" id="461">
<td><a id="l461" class='ln'>461</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="462" id="462">
<td><a id="l462" class='ln'>462</a></td><td>      <span class="kw">if</span> (<a id="462c11" class="tk">IdType</a> <a id="462c18" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="463" id="463">
<td><a id="l463" class='ln'>463</a></td><td>        <a id="463c9" class="tk">FLEXCAN</a>(<a id="463c17" class="tk">Module</a>).<a id="463c25" class="tk">MB</a>[<a id="463c28" class="tk">BufNum</a>].<a id="463c36" class="tk">CS</a>.<a id="463c39" class="tk">B</a>.<a id="463c41" class="tk">IDE</a> = <a id="463c47" class="tk">MB_IDType_ST</a>;</td></tr>
<tr name="464" id="464">
<td><a id="l464" class='ln'>464</a></td><td>        <a id="464c9" class="tk">FLEXCAN</a>(<a id="464c17" class="tk">Module</a>).<a id="464c25" class="tk">MB</a>[<a id="464c28" class="tk">BufNum</a>].<a id="464c36" class="tk">ID</a>.<a id="464c39" class="tk">B</a>.<a id="464c41" class="tk">ID_STD</a> = <a id="464c50" class="tk">Id</a>;</td></tr>
<tr name="465" id="465">
<td><a id="l465" class='ln'>465</a></td><td>        <a id="465c9" class="tk">FLEXCAN</a>(<a id="465c17" class="tk">Module</a>).<a id="465c25" class="tk">MB</a>[<a id="465c28" class="tk">BufNum</a>].<a id="465c36" class="tk">CS</a>.<a id="465c39" class="tk">B</a>.<a id="465c41" class="tk">SRR</a> = 0;</td></tr>
<tr name="466" id="466">
<td><a id="l466" class='ln'>466</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="467" id="467">
<td><a id="l467" class='ln'>467</a></td><td>        <a id="467c9" class="tk">FLEXCAN</a>(<a id="467c17" class="tk">Module</a>).<a id="467c25" class="tk">MB</a>[<a id="467c28" class="tk">BufNum</a>].<a id="467c36" class="tk">CS</a>.<a id="467c39" class="tk">B</a>.<a id="467c41" class="tk">IDE</a> = <a id="467c47" class="tk">MB_IDType_EX</a>;</td></tr>
<tr name="468" id="468">
<td><a id="l468" class='ln'>468</a></td><td>        <a id="468c9" class="tk">FLEXCAN</a>(<a id="468c17" class="tk">Module</a>).<a id="468c25" class="tk">MB</a>[<a id="468c28" class="tk">BufNum</a>].<a id="468c36" class="tk">ID</a>.<a id="468c39" class="tk">R</a> = (<a id="468c44" class="tk">uint32</a>)(<a id="468c52" class="tk">Id</a><a id="468c54" class="tk">&amp;</a>0x1FFFFFFF);</td></tr>
<tr name="469" id="469">
<td><a id="l469" class='ln'>469</a></td><td>        <a id="469c9" class="tk">FLEXCAN</a>(<a id="469c17" class="tk">Module</a>).<a id="469c25" class="tk">MB</a>[<a id="469c28" class="tk">BufNum</a>].<a id="469c36" class="tk">CS</a>.<a id="469c39" class="tk">B</a>.<a id="469c41" class="tk">SRR</a> = 1;</td></tr>
<tr name="470" id="470">
<td><a id="l470" class='ln'>470</a></td><td>      <span class="br">}</span></td></tr>
<tr name="471" id="471">
<td><a id="l471" class='ln'>471</a></td><td></td></tr>
<tr name="472" id="472">
<td><a id="l472" class='ln'>472</a></td><td>      <a id="472c7" class="tk">FLEXCAN</a>(<a id="472c15" class="tk">Module</a>).<a id="472c23" class="tk">MB</a>[<a id="472c26" class="tk">BufNum</a>].<a id="472c34" class="tk">CS</a>.<a id="472c37" class="tk">B</a>.<a id="472c39" class="tk">RTR</a> = 0;</td></tr>
<tr name="473" id="473">
<td><a id="l473" class='ln'>473</a></td><td>      <span class="kw">for</span> (<a id="473c12" class="tk">i</a>=0; <a id="473c17" class="tk">i</a><a id="473c18" class="tk">&lt;</a><a id="473c19" class="tk">DataLength</a>; <a id="473c31" class="tk">i</a><a id="473c32" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="474" id="474">
<td><a id="l474" class='ln'>474</a></td><td>        <a id="474c9" class="tk">FLEXCAN</a>(<a id="474c17" class="tk">Module</a>).<a id="474c25" class="tk">MB</a>[<a id="474c28" class="tk">BufNum</a>].<a id="474c36" class="tk">DATA</a>.<a id="474c41" class="tk">B</a>[<a id="474c43" class="tk">i</a>] = <a id="474c48" class="tk">Tx_Buffer</a>[<a id="474c58" class="tk">i</a>];</td></tr>
<tr name="475" id="475">
<td><a id="l475" class='ln'>475</a></td><td>      <span class="br">}</span></td></tr>
<tr name="476" id="476">
<td><a id="l476" class='ln'>476</a></td><td></td></tr>
<tr name="477" id="477">
<td><a id="l477" class='ln'>477</a></td><td>      <a id="477c7" class="tk">FLEXCAN</a>(<a id="477c15" class="tk">Module</a>).<a id="477c23" class="tk">MB</a>[<a id="477c26" class="tk">BufNum</a>].<a id="477c34" class="tk">CS</a>.<a id="477c37" class="tk">B</a>.<a id="477c39" class="tk">DLC</a> = <a id="477c45" class="tk">DataLength</a>;</td></tr>
<tr name="478" id="478">
<td><a id="l478" class='ln'>478</a></td><td>      <a id="478c7" class="tk">FLEXCAN</a>(<a id="478c15" class="tk">Module</a>).<a id="478c23" class="tk">MB</a>[<a id="478c26" class="tk">BufNum</a>].<a id="478c34" class="tk">CS</a>.<a id="478c37" class="tk">B</a>.<a id="478c39" class="tk">CODE</a> = <a id="478c46" class="tk">TX_MB_CODE_TRANSMIT</a>;</td></tr>
<tr name="479" id="479">
<td><a id="l479" class='ln'>479</a></td><td>      <a id="479c7" class="tk">result</a> = <a id="479c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="480" id="480">
<td><a id="l480" class='ln'>480</a></td><td>      <a id="480c7" class="tk">ec_can_appltxconfirmation</a>(<a id="480c33" class="tk">Module</a>,<a id="480c40" class="tk">BufNum</a>);</td></tr>
<tr name="481" id="481">
<td><a id="l481" class='ln'>481</a></td><td>    <span class="br">}</span></td></tr>
<tr name="482" id="482">
<td><a id="l482" class='ln'>482</a></td><td>  <span class="br">}</span></td></tr>
<tr name="483" id="483">
<td><a id="l483" class='ln'>483</a></td><td></td></tr>
<tr name="484" id="484">
<td><a id="l484" class='ln'>484</a></td><td>  <span class="kw">return</span>(<a id="484c10" class="tk">result</a>);</td></tr>
<tr name="485" id="485">
<td><a id="l485" class='ln'>485</a></td><td><span class="br">}</span></td></tr>
<tr name="486" id="486">
<td><a id="l486" class='ln'>486</a></td><td></td></tr>
<tr name="487" id="487">
<td><a id="l487" class='ln'>487</a></td><td><a id="487c1" class="tk">CAN_Return</a> <a id="487c12" class="tk">ec_remote_transmit</a>(<a id="487c31" class="tk">uint8</a> <a id="487c37" class="tk">Module</a>,<a id="487c44" class="tk">uint8</a> <a id="487c50" class="tk">BufNum</a>,<a id="487c57" class="tk">uint8</a> <a id="487c63" class="tk">IdType</a>,<a id="487c70" class="tk">uint32</a> <a id="487c77" class="tk">Id</a>)</td></tr>
<tr name="488" id="488">
<td><a id="l488" class='ln'>488</a></td><td><span class="br">{</span></td></tr>
<tr name="489" id="489">
<td><a id="l489" class='ln'>489</a></td><td>  <a id="489c3" class="tk">uint8</a> <a id="489c9" class="tk">i</a>;</td></tr>
<tr name="490" id="490">
<td><a id="l490" class='ln'>490</a></td><td>  <a id="490c3" class="tk">CAN_Return</a> <a id="490c14" class="tk">result</a> = <a id="490c23" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="491" id="491">
<td><a id="l491" class='ln'>491</a></td><td>  <span class="kw">if</span> (<a id="491c7" class="tk">BufNum</a><a id="491c13" class="tk">&lt;</a>8)</td></tr>
<tr name="492" id="492">
<td><a id="l492" class='ln'>492</a></td><td>    <a id="492c5" class="tk">BufNum</a> = 8;</td></tr>
<tr name="493" id="493">
<td><a id="l493" class='ln'>493</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> ((<a id="493c13" class="tk">BufNum</a><a id="493c19" class="tk">&gt;</a>15)<a id="493c23" class="tk">&amp;</a>(<a id="493c25" class="tk">BufNum</a><a id="493c31" class="tk">&lt;</a>56))</td></tr>
<tr name="494" id="494">
<td><a id="l494" class='ln'>494</a></td><td>    <a id="494c5" class="tk">BufNum</a> = 15;</td></tr>
<tr name="495" id="495">
<td><a id="l495" class='ln'>495</a></td><td>  <span class="kw">else</span> <span class="kw">if</span> (<a id="495c12" class="tk">BufNum</a><a id="495c18" class="tk">&gt;</a>63)</td></tr>
<tr name="496" id="496">
<td><a id="l496" class='ln'>496</a></td><td>    <a id="496c5" class="tk">BufNum</a> = 63;</td></tr>
<tr name="497" id="497">
<td><a id="l497" class='ln'>497</a></td><td>  <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="498" id="498">
<td><a id="l498" class='ln'>498</a></td><td>    <span class="kw">if</span> (<a id="498c9" class="tk">FLEXCAN</a>(<a id="498c17" class="tk">Module</a>).<a id="498c25" class="tk">MB</a>[<a id="498c28" class="tk">BufNum</a>].<a id="498c36" class="tk">CS</a>.<a id="498c39" class="tk">B</a>.<a id="498c41" class="tk">CODE</a> <a id="498c46" class="tk">==</a> <a id="498c49" class="tk">TX_MB_CODE_TRANSMIT</a>) <span class="br">{</span></td></tr>
<tr name="499" id="499">
<td><a id="l499" class='ln'>499</a></td><td>      <a id="499c7" class="tk">result</a> = <a id="499c16" class="tk">CAN_BUSY</a>;</td></tr>
<tr name="500" id="500">
<td><a id="l500" class='ln'>500</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="501" id="501">
<td><a id="l501" class='ln'>501</a></td><td>      <span class="kw">if</span> (<a id="501c11" class="tk">IdType</a> <a id="501c18" class="tk">==</a> 0) <span class="br">{</span></td></tr>
<tr name="502" id="502">
<td><a id="l502" class='ln'>502</a></td><td>        <a id="502c9" class="tk">FLEXCAN</a>(<a id="502c17" class="tk">Module</a>).<a id="502c25" class="tk">MB</a>[<a id="502c28" class="tk">BufNum</a>].<a id="502c36" class="tk">CS</a>.<a id="502c39" class="tk">B</a>.<a id="502c41" class="tk">IDE</a> = <a id="502c47" class="tk">MB_IDType_ST</a>;</td></tr>
<tr name="503" id="503">
<td><a id="l503" class='ln'>503</a></td><td>        <a id="503c9" class="tk">FLEXCAN</a>(<a id="503c17" class="tk">Module</a>).<a id="503c25" class="tk">MB</a>[<a id="503c28" class="tk">BufNum</a>].<a id="503c36" class="tk">ID</a>.<a id="503c39" class="tk">B</a>.<a id="503c41" class="tk">ID_STD</a> = <a id="503c50" class="tk">Id</a>;</td></tr>
<tr name="504" id="504">
<td><a id="l504" class='ln'>504</a></td><td>        <a id="504c9" class="tk">FLEXCAN</a>(<a id="504c17" class="tk">Module</a>).<a id="504c25" class="tk">MB</a>[<a id="504c28" class="tk">BufNum</a>].<a id="504c36" class="tk">CS</a>.<a id="504c39" class="tk">B</a>.<a id="504c41" class="tk">SRR</a> = 0;</td></tr>
<tr name="505" id="505">
<td><a id="l505" class='ln'>505</a></td><td>      <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="506" id="506">
<td><a id="l506" class='ln'>506</a></td><td>        <a id="506c9" class="tk">FLEXCAN</a>(<a id="506c17" class="tk">Module</a>).<a id="506c25" class="tk">MB</a>[<a id="506c28" class="tk">BufNum</a>].<a id="506c36" class="tk">CS</a>.<a id="506c39" class="tk">B</a>.<a id="506c41" class="tk">IDE</a> = <a id="506c47" class="tk">MB_IDType_EX</a>;</td></tr>
<tr name="507" id="507">
<td><a id="l507" class='ln'>507</a></td><td>        <a id="507c9" class="tk">FLEXCAN</a>(<a id="507c17" class="tk">Module</a>).<a id="507c25" class="tk">MB</a>[<a id="507c28" class="tk">BufNum</a>].<a id="507c36" class="tk">ID</a>.<a id="507c39" class="tk">R</a> = (<a id="507c44" class="tk">uint32</a>)(<a id="507c52" class="tk">Id</a><a id="507c54" class="tk">&amp;</a>0x1FFFFFFF);</td></tr>
<tr name="508" id="508">
<td><a id="l508" class='ln'>508</a></td><td>        <a id="508c9" class="tk">FLEXCAN</a>(<a id="508c17" class="tk">Module</a>).<a id="508c25" class="tk">MB</a>[<a id="508c28" class="tk">BufNum</a>].<a id="508c36" class="tk">CS</a>.<a id="508c39" class="tk">B</a>.<a id="508c41" class="tk">SRR</a> = 1;</td></tr>
<tr name="509" id="509">
<td><a id="l509" class='ln'>509</a></td><td>      <span class="br">}</span></td></tr>
<tr name="510" id="510">
<td><a id="l510" class='ln'>510</a></td><td></td></tr>
<tr name="511" id="511">
<td><a id="l511" class='ln'>511</a></td><td>      <a id="511c7" class="tk">FLEXCAN</a>(<a id="511c15" class="tk">Module</a>).<a id="511c23" class="tk">MB</a>[<a id="511c26" class="tk">BufNum</a>].<a id="511c34" class="tk">CS</a>.<a id="511c37" class="tk">B</a>.<a id="511c39" class="tk">RTR</a> = 1;</td></tr>
<tr name="512" id="512">
<td><a id="l512" class='ln'>512</a></td><td>      <a id="512c7" class="tk">FLEXCAN</a>(<a id="512c15" class="tk">Module</a>).<a id="512c23" class="tk">MB</a>[<a id="512c26" class="tk">BufNum</a>].<a id="512c34" class="tk">CS</a>.<a id="512c37" class="tk">B</a>.<a id="512c39" class="tk">DLC</a> = 8;</td></tr>
<tr name="513" id="513">
<td><a id="l513" class='ln'>513</a></td><td>      <a id="513c7" class="tk">FLEXCAN</a>(<a id="513c15" class="tk">Module</a>).<a id="513c23" class="tk">MB</a>[<a id="513c26" class="tk">BufNum</a>].<a id="513c34" class="tk">CS</a>.<a id="513c37" class="tk">B</a>.<a id="513c39" class="tk">CODE</a> = <a id="513c46" class="tk">TX_MB_CODE_TRANSMIT</a>;</td></tr>
<tr name="514" id="514">
<td><a id="l514" class='ln'>514</a></td><td>      <a id="514c7" class="tk">result</a> = <a id="514c16" class="tk">CAN_OK</a>;</td></tr>
<tr name="515" id="515">
<td><a id="l515" class='ln'>515</a></td><td>    <span class="br">}</span></td></tr>
<tr name="516" id="516">
<td><a id="l516" class='ln'>516</a></td><td>  <span class="br">}</span></td></tr>
<tr name="517" id="517">
<td><a id="l517" class='ln'>517</a></td><td></td></tr>
<tr name="518" id="518">
<td><a id="l518" class='ln'>518</a></td><td>  <span class="kw">return</span>(<a id="518c10" class="tk">result</a>);</td></tr>
<tr name="519" id="519">
<td><a id="l519" class='ln'>519</a></td><td><span class="br">}</span></td></tr>
<tr name="520" id="520">
<td><a id="l520" class='ln'>520</a></td><td></td></tr>
<tr name="521" id="521">
<td><a id="l521" class='ln'>521</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="522" id="522">
<td><a id="l522" class='ln'>522</a></td><td></td></tr>
<tr name="523" id="523">
<td><a id="l523" class='ln'>523</a></td><td><span class="ct">/* File trailer for ECUCoder generated file can.c.</span></td></tr>
<tr name="524" id="524">
<td><a id="l524" class='ln'>524</a></td><td><span class="ct"> *</span></td></tr>
<tr name="525" id="525">
<td><a id="l525" class='ln'>525</a></td><td><span class="ct"> * [EOF]</span></td></tr>
<tr name="526" id="526">
<td><a id="l526" class='ln'>526</a></td><td><span class="ct"> */</span></td></tr>
<tr name="527" id="527">
<td><a id="l527" class='ln'>527</a></td><td></td></tr>
</table>
</pre>
</body>
</html>
